Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose more of RE2's matching interface #120

Closed
wants to merge 0 commits into from
Closed

Conversation

mudge
Copy link
Owner

@mudge mudge commented Nov 30, 2023

GitHub: #119

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

  • anchor: specifying whether a match should be unanchored (the default), anchored to the start of the text or anchored to both ends
  • startpos: the offset at which to start matching (defaults to the start of the text)
  • submatches: the number of submatches to extract (defaults to the number of capturing groups in the pattern)

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.

@mudge mudge force-pushed the matching-interface branch 7 times, most recently from ef2a857 to 05c28b9 Compare December 4, 2023 21:01
@mudge mudge marked this pull request as ready for review December 4, 2023 21:07
@mudge mudge force-pushed the matching-interface branch 5 times, most recently from 6f93366 to 5af98d1 Compare December 5, 2023 19:46
@mudge mudge closed this Dec 5, 2023
@mudge mudge force-pushed the matching-interface branch from 5af98d1 to b04b9d9 Compare December 5, 2023 20:09
@mudge mudge deleted the matching-interface branch December 5, 2023 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant