diff options
Diffstat (limited to 'bs/re.scm')
-rw-r--r-- | bs/re.scm | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -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))) |