diff options
author | Ben Sima <ben@bsima.me> | 2022-07-23 22:24:34 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2022-07-23 22:31:34 -0400 |
commit | f91d101dffb51c8eb207914833d1a5241149ae7b (patch) | |
tree | e0d8e3a036e377a93e84dc2a35c9994a511f3ca6 /bs/re.scm | |
parent | 19dd1eef9d279aa468d4e179abad375d7271dc2a (diff) |
Move comments to docstrings
Just spent an hour implementing my own doc system, just to find out this is
built in to guile :(
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))) |