tst2005googlecode / re2

Automatically exported from code.google.com/p/re2
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

one_line option and perl style REs don't work together #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If I do options.set_one_line(false); but don't set POSIX regexps one_line is 
actually set to true as it's part of the LikePerl set defined in regexp.h. Now 
I actually read the docs I see this is sort of documented (although rather 
vaguely). However this means it's impossible to get Perl alike behaviour (as 
some of the flags set by LikePerl are not exposed by the other options).

For now I think I'm going to modify this in my copy 
(http://github.com/dgl/re-engine-RE2 by just not including OneLine in the perl 
flags), but obviously that changes the API; I'm not sure what the cleanest 
backwards compatible way (if there even is).

Thanks,
David

Original issue reported on code.google.com by dgl...@gmail.com on 4 Aug 2010 at 1:03

GoogleCodeExporter commented 9 years ago
The one_line setting only applies to POSIX mode because Perl syntax
already provides a way to control it: insert (?m) at the beginning of
the regexp.  For more details see http://perldoc.perl.org/perlre.html#Modifiers

Original comment by rsc@golang.org on 4 Aug 2010 at 5:31

GoogleCodeExporter commented 9 years ago
Guess I'll just keep this in my fork then; it seems silly to need an allocation 
to add (?m) to the start of the string I'm given. Thanks for the reply anyway.

Original comment by dgl...@gmail.com on 5 Aug 2010 at 8:10

GoogleCodeExporter commented 9 years ago
There is one downside of requiring "(?m)" as a work-around.  I maintain a 
program that takes regular expressions from users and always has to run in 
multiline mode.  If I accomplish this by prepending "(?m)" to the regular 
expression, but they have a syntax error, then the "(?m)" will appear in the 
error message, which would be confusing to the user.

Would you accept a patch that added a "multi_line" option to the Options 
structure that overrode the OneLine bit after LikePerl was applied?

Original comment by dre...@gmail.com on 11 Nov 2010 at 6:40