(re-matches re s)
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"]
;; Note: See clojure.core/subs for discussion of behavior of substrings
;; holding onto references of the original strings, which can
;; significantly affect your memory usage in some cases.
; Regex match flags can be embedded in the regex string. So, we can convert the normal case-sensitive matching into case-insensitive matching.
user=> (re-matches #"hello" "HELLO") ; case-sensitive
nil
user=> (re-matches #"(?i)hello" "hello") ; case-insensitive
"hello"
user=> (re-matches #"(?i)hello" "HELLO") ; case-insensitive
"HELLO"
user=> (re-matches #"(?i)HELLO" "heLLo") ; case-insensitive
"heLLo"