function | since v0.0-927 | clojure.core/re-find | Edit |
(re-find re s)
Returns the first regex match, if any, of s
to re
, using re.exec(s)
.
Returns a vector, containing first the matching substring, then any capturing groups if the regular expression contains capturing groups.
Returns the first regex match, if any, of s to re, using re.exec(s). Returns a vector, containing first the matching substring, then any capturing groups if the regular expression contains capturing groups.
(defn re-find
[re s]
(if (string? s)
(let [matches (.exec re s)]
(when-not (nil? matches)
(if (== (count ^array matches) 1)
(aget matches 0)
(vec matches))))
(throw (js/TypeError. "re-find must match against a string."))))