december has asked for the wisdom of the Perl Monks concerning the following question:
Hello fellow monks,
A quick question:
Why doesn't the first regex match while the second does?
$ perl -e '$_ = "(b)."; /\((?=a|b|c)\)/ && do { print "match!\n"; };' $ perl -e '$_ = "(b)."; /\((?=a|b|c)/ && do { print "match!\n"; };' match!
It's probably very simple and it has something to do with the use of grouping brackets instead of regular capturing brackets, but I don't seem to get why one works and the other doesn't – it's Monday and so far my brain has refused to accept that fact.
Thanks for any pointers!
EDIT: It's a typo. I overlooked the fact I typed an equal sign instead of a colon, accidently making it a look-ahead regex. Monday just isn't my day. Sorry folks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Why does this simple grouping regex not match?
by moritz (Cardinal) on Feb 28, 2011 at 13:34 UTC | |
by december (Pilgrim) on Feb 28, 2011 at 13:59 UTC | |
by Anonymous Monk on Feb 28, 2011 at 14:10 UTC | |
by december (Pilgrim) on Mar 01, 2011 at 11:41 UTC | |
Re: Why does this simple grouping regex not match?
by fisher (Priest) on Feb 28, 2011 at 13:38 UTC | |
Re: Why does this simple grouping regex not match?
by Anonymous Monk on Feb 28, 2011 at 13:58 UTC | |
by december (Pilgrim) on Mar 01, 2011 at 11:46 UTC | |
Re: Why does this simple grouping regex not match?
by umasuresh (Hermit) on Feb 28, 2011 at 13:35 UTC |
Back to
Seekers of Perl Wisdom