Skip to content

Matching with regex groupsλ︎

rematches takes a pattern and compares it with a string.

If the pattern does not match the string then nil is returned to show the function returned a false value.

(re-matches #"pumpkin" "Halloween pumpkin")
 ```

If there is an exact match and there are no groups (parens) in the regex, then the matched string is returned.

```clojure
(re-matches #"pumpkin" "pumpkin")

If the pattern matches but there are groups, a vector of matching strings is returned. The first element in the vector is the entire match. The remaining elements are the group matches.

(re-matches #"Halloween(.*)" "Halloween pumpkin")