[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] /AAA|BBB/



(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