Returns a lazy sequence of successive matches of pattern in string,
using java.util.regex.Matcher.find(), each such match processed with
re-groups.
;; Parenthesized groups in the regex cause each returned match to be a ;; vector of matched strings. See re-find for more examples. user=> (def line " RX pkts:18 err:5 drop:48") #'user/line user=> (re-seq #"(\S+):(\d+)" line) (["pkts:18" "pkts" "18"] ["err:5" "err" "5"] ["drop:48" "drop" "48"])
(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))))))))
Comments top
No comments for re-seq. Log in to add a comment.