mudge/re2

Expose more of the matching interface in Ruby

mudge opened this issue · 2 comments

mudge commented

When I first wrote this gem about a decade(!) ago, I naïvely intended it to be a drop-in replacement for Ruby’s Regexp standard library. However, RE2 not only doesn’t have the same syntax as Ruby’s regular expressions but it has its own unique capabilities that we’re not taking advantage of by hiding it behind a restrictive Ruby API.

Already, RE2::Regexp#match has some poorly documented functionality that is unique to RE2: the ability to specify the exact number of submatches when performing a match which has a significant effect on performance. This should not only be better explained but be a core part of the API along with the other arguments to Match: startpos, endpos (not available on all versions of RE2) and anchor.

This would also create a natural opportunity to introduce the higher-level FullMatch and PartialMatch APIs.

mudge commented

It's also worth nothing that Google's own documentation for RE2 only focusses on FullMatch and PartialMatch and doesn't mention other parts of the API so we should at least offer Ruby analogues.

mudge commented

Version 2.5.0 now exposes the full underlying Match interface upon which the new full_match and partial_match APIs are built.