Created
April 1, 2020 10:35
-
-
Save sw1nn/1d9e6bf0ed76309021caed9c3b9fb457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn re-seq | |
"Returns a lazy sequence of successive matches of pattern in string, | |
using java.util.regex.Matcher.find(), each such match processed with | |
re-groups." | |
{:added "1.0" | |
:static true} | |
[^java.util.regex.Pattern re s] | |
(let [m (re-matcher re s)] | |
((fn step [] | |
(when (. m (find)) | |
(cons (re-groups m) (lazy-seq (step)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment