Returns the match, if any, of string to pattern, using
java.util.regex.Matcher.matches(). Uses re-groups to return the
groups.
;; The distinction is that re-find tries to find _any part_ of the string ;; that matches the pattern, but re-matches only matches if the _entire_ ;; string matches the pattern. user=> (re-matches #"hello" "hello, world") nil user=> (re-matches #"hello.*" "hello, world") "hello, world" user=> (re-matches #"hello, (.*)" "hello, world") ["hello, world" "world"]
(defn re-matches
"Returns the match, if any, of string to pattern, using
java.util.regex.Matcher.matches(). Uses re-groups to return the
groups."
{:added "1.0"}
[^java.util.regex.Pattern re s]
(let [m (re-matcher re s)]
(when (. m (matches))
(re-groups m))))
Comments top
No comments for re-matches. Log in to add a comment.