1 Jan 2012 19:07
`regexp-explode' etc + poll
I've implemented a new `regexp-explode' function. It accepts the same
arguments as `regexp-match*' and `regexp-split', but with two
additional keyword arguments:
* #:select-match
If this is #t (the default) then the result includes the lists of
results from the sub-matches. It can also be #f to not include
them, and it can be a "selector function" that chooses a specific
one (eg, `car' etc) or return a different list of matches (eg,
`cdr').
* #:select-gap
This is just a boolean flag -- if it's #t (the default), the
strings between the matches are returned as well -- interleaved
with the (lists of) matches, otherwise they're omitted.
So by default, you get the information that `regexp-split' returns,
interleaved with the full results of matching. Examples:
-> (regexp-explode #rx"[^0-9]([^0-9])?" "0+1.*2")
'("0" ("+" #f) "1" (".*" "*") "2")
-> (regexp-explode #rx"[^0-9]([^0-9])?" "0+1.*2"
#:select-match car #:select-gap #f)
'("+" ".*")
-> (regexp-explode #rx"[^0-9]([^0-9])?" "0+1.*2"
#:select-match cadr)
'("0" #f "1" "*" "2")
(Continue reading)
RSS Feed