[Omaha.pm] /AAA|BBB/
Jay Hannah
jay at jays.net
Thu Feb 2 13:01:32 PST 2006
>>>>(2) What does this print (what does adding parens change)?:
>>>
>>>Adding parens doesn't change anything as far as what matches or
>>>doesn't. It only captures the match.
>>
>>Sure it does, sometimes. Parens allow for multi-character control
>>of the | character while matching. That's why I always use them.
>
> I meant in the two examples given, of /AAA|BBB/ and /(AAA|BBB)/
Ya. But I'm not smart enough to remember that I need to remember parens sometimes, so years ago I just started using /^(xxx|yyy)$/ for all my switch-esque operations, just to be safe.
I'm certainly too lazy to remember /^(?:xxx|yyy)$/ ... I think. Yup, I'm probably too lazy to remember that.
Grin,
j
More information about the Omaha-pm
mailing list