clojure.core/re-find¶
Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups.
Examples¶
Note by paomian¶
the regex can't be a var?
this will get an error!Note by blx¶
@paomian: The regex can be a variable, but the variable needs to be a regex.
This works fine:
(let [regex #"abc"] (re-find regex "abc"))
because the # reader macro for declaring regexes applies to the string right after it -- without doing any kind of substitution.
You could also do
(let [regex "abc"] (re-find (re-pattern regex) "abc"))
See also¶
- clojure.core/re-groups (0)
- clojure.core/re-matcher (0)
- clojure.core/re-pattern
- clojure.core/re-seq (4)
- clojure.core/re-matches (3)
- clojure.core/subs (3)
- clojure.string/replace (8)
Content from the matching ClojureDocs page, with authors credited on each contribution.