mudge/re2

Access to RE2::MatchData via RE2::Scanner

lupine opened this issue · 2 comments

Hi,

Today I had occasion to try to replace a usage of the Ruby Regexp class like:

"foo".scan(/(.)/) {|match| ... }

with an RE2 regular expression.

I quickly ran up against the fact that RE2::Scanner#scan returns Array<String> rather than Array<RE2::MatchData>.

In my case, I want access to the begin and end metadata that the RE2::MatchData would carry.

Is this something you'd accept a PR for?

It's possible I'll be able to use ReplaceAll instead, in this particular case, or work around it another way, so I can't guarantee I'll put one together, but I wanted to assess the likelihood of it being accepted early :)

mudge commented

Hi @lupine,

I’d be happy to review a PR for that but we’d need to introduce a new API for it to avoid breaking compatibility. Perhaps another method on Scanner or a separate class altogether?

mudge commented

As there's been no activity on this issue for over a year, I'll close it in a week unless there's an update.