http://qs321.pair.com?node_id=890557

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!