Named capture cannot be nested inside case-insensitive group
BanzaiMan opened this issue · 2 comments
BanzaiMan commented
Compare:
2.0.0p247 :008 > re2 = RE2('(?i:(?<abc>abc))')
re2/re2.cc:197: Error parsing '(?i:(?<abc>abc))': invalid perl operator: (?<
=> #<RE2::Regexp /(?i:(?<abc>abc))/>
and
2.0.0p247 :009 > re = Regexp.new '(?i:(?<abc>abc))'
=> /(?i:(?<abc>abc))/
2.0.0p247 :011 > re.match('abc')
=> #<MatchData "abc" abc:"abc">
Not sure if this is supported by re2.
mudge commented
That syntax is not valid for re2: see the official re2 syntax page for full compatibility. Specifically, using (?<name>re)
is unsupported; you should use (?P<name>re)
instead like so:
> RE2('(?i:(?P<abc>abc))').match('abc')
=> #<RE2::MatchData "abc" 1:"abc">
BanzaiMan commented
Thanks for the explanation.