rencg.api
re-find-ncg
multimethod
(re-find-ncg m)
(re-find-ncg m ncgs)
(re-find-ncg re s)
(re-find-ncg re s ncgs)
Equivalent to clojure.core/re-find, but returns the result of calling re-groups-ncg when the pattern is found, or nil
otherwise.
If multiple finds are being performed, the versions where the sequence of named-capturing groups is passed in may be more efficient as they allow the caller to calculate the named-capturing groups in the regex once, then reuse that information, potentially avoiding re-parsing of the regex on each call.
re-groups-ncg
(re-groups-ncg m)
(re-groups-ncg m ncgs)
Equivalent to clojure.core/re-groups, but instead of returning a sequence containing the entire match and each group, it returns a map of the named-capturing groups as well as the start index (:start
), end index (:end
), and text (:match
) of the entire match.
The key for each named-capturing group that’s found is the (String
) name of that group, and the corresponding value is the (String
) text that matched that group.
If the same regex is being used many times, the 2-arg version may be more efficient as it allows the caller to calculate the named-capturing groups in the regex once, then reuse that information, potentially avoiding re-parsing of the regex on each call.
re-matches-ncg
(re-matches-ncg re s)
(re-matches-ncg re s ncgs)
Equivalent to clojure.core/re-matches, but returns the result of calling re-groups-ncg when there’s a match, or nil
otherwise.
If the regex is being reused many times, the 3-arg version may be more efficient as it allows the caller to calculate the named-capturing groups in the regex once, then reuse that information, potentially avoiding re-parsing of the regex on each call.
re-named-groups
multimethod
(re-named-groups re)
(re-named-groups m)
Returns the names of all of the named-capturing groups in the given regular expression (java.util.regex.Pattern
) or matcher (java.util.regex.Matcher
) as a set of String
s, or an empty set if there aren’t any.
Note: on older JDKs (pre v20), this uses a JDK-agnostic workaround for JDK-7032377.
re-seq-ncg
(re-seq-ncg re s)
(re-seq-ncg re s ncgs)
Equivalent to clojure.core/re-seq, but returns the result of calling re-groups-ncg on each successive match, or nil
if there are no matches.
If the regex is being reused many times, the 3-arg version may be more efficient as it allows the caller to calculate the named-capturing groups in the regex once, then reuse that information, potentially avoiding re-parsing of the regex on each call.