* Imported original elk 3.0 tree.

git-svn-id: svn://svn.zoy.org/elk/trunk@1 55e467fa-43c5-0310-a8a2-de718669efc6
This commit is contained in:
sam
2003-08-19 19:19:38 +00:00
commit 3132f65611
397 changed files with 78872 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
;;; -*-Scheme-*-
;;;
;;; Demonstrate the regular expression primitives.
(require 'regexp)
;; Returns a list of substrings of string `str' that match the
;; pattern `pat'
(define (matches str pat)
(let loop ((r (make-regexp pat '(extended))) (result '()) (from 0))
(let ((m (regexp-exec r str from)))
(if (regexp-match? m)
(loop r (cons (substring str (+ from (regexp-match-start m 0))
(+ from (regexp-match-end m 0)))
result)
(+ from (regexp-match-end m 0)))
(reverse result)))))
(require 'siteinfo)
(cond
((feature? ':regular-expressions)
(print (matches "Hello, world!" "[a-zA-z]+"))
(print (matches "Hello, world!" ".")))
(else
(format #t "Regular expressions not supported by ~a-~a~%"
site-machine site-os)))