Support Regexp options
sk- opened this issue · 3 comments
Currently in ruby you would define a new case insensitive regexp as Regexp.new(..., Regexp::IGNORECASE)
. However in re2
you need to specify it as RE2::Regexp.new(..., case_sensitive: false)
, which means that you cannot just replace Regexp
with RE2::Regexp
.
See http://ruby-doc.org/core-2.2.0/Regexp.html#method-i-options for the full list of options
The issue of whether re2 should 100% match Ruby's own Regexp
API has come up before and I still feel the same way: after all, the underlying Google re2 library is not 100% feature compatible with Ruby's regular expression engine so trying to provide an identical API may be impossible.
Perhaps the issue is that RE2::Regexp
is a bit of an uncanny valley and looks enough like Ruby's Regexp
to cause this confusion.
Might it be better to set expectations that you can't just drop re2 in without some modification and how would we best go about this?
Could you add a section to the Readme stating the differences and incompatibilities of re2
compared to ruby's Regexp
.
I got confused by the statement in the Usage section: You can use re2 as a mostly drop-in replacement for Ruby's own Regexp and MatchData classes
.
Good idea: I agree that sentence is definitely misleading.