mudge / re2

Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python".
http://mudge.name/re2/
BSD 3-Clause "New" or "Revised" License
129 stars 13 forks source link

Expose more of RE2's matching interface #120

Closed mudge closed 9 months ago

mudge commented 9 months ago

GitHub: https://github.com/mudge/re2/issues/119

Add new options to RE2::Regexp#match that expose the underlying capabilities of RE2's Match function:

We keep compatibility with the previous API by still accepting a number of submatches as the second argument to match.

With these new options in place, we can now offer a higher-level RE2::Regexp#full_match and RE2::Regexp#partial_match API to match RE2's own. Note we don't actually use the underlying FullMatchN or PartialMatchN functions as we need to use Match's behaviour of returning the overall match first before any extracted submatches.

The plan is to then heavily promote these two methods over the lower-level match.