summaryrefslogtreecommitdiff
path: root/bs/re.scm
diff options
context:
space:
mode:
Diffstat (limited to 'bs/re.scm')
-rw-r--r--bs/re.scm23
1 files changed, 11 insertions, 12 deletions
diff --git a/bs/re.scm b/bs/re.scm
index 926aae7..ec5b2ba 100644
--- a/bs/re.scm
+++ b/bs/re.scm
@@ -27,30 +27,29 @@
;; (define M regexp/newline)
;; (define MULTILINE regexp/newline)
- ;; Compile `pattern` into a regular expression object.
(define (compile pattern . flags)
+ "Compile `pattern` into a regular expression object."
(apply make-regexp (cons pattern flags)))
- ;; If zero or more characters at the beginning of `string` match the
- ;; regular expression `pattern`, return a corresponding match object.
+
(define (match string pattern)
+ "If zero or more characters at the beginning of `string` match the regular
+expression `pattern`, return a corresponding match object."
(regexp-exec pattern string))
- ;;
(define (group match-obj n)
(if match-obj
(match:substring match-obj n)
#f))
- ;; Return the string obtained by replacing the leftmost
- ;; non-overlapping occurrences of `pattern` in `string` by the
- ;; replacement `repl`. If the pattern isn’t found, string is returned
- ;; unchanged.
(define (sub string pattern repl)
+ "Return the string obtained by replacing the leftmost non-overlapping
+occurrences of `pattern` in `string` by the replacement `repl`. If the pattern
+isn’t found, string is returned unchanged."
(regexp-replace pattern string repl))
- ;; Scan through `string` looking for the first location where the
- ;; regular expression `pattern` produces a match, and return a
- ;; corresponding match object. Returns `#f` if no match is found.
(define (search string pattern)
- (regexp-exec pattern string)))
+ "Scan through `string` looking for the first location where the regular
+expression `pattern` produces a match, and return a corresponding match
+object. Returns `#f` if no match is found."
+ (string-match pattern string)))