Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: how can I combine these expressions?by chromatic (Archbishop) |
on Jul 27, 2000 at 02:44 UTC ( [id://24590]=note: print w/replies, xml ) | Need Help?? |
Why not just stick a ? after each brace? That means 'match zero or one times'. I don't see anything different that happens if the variable's braced, but my brain hurts today so definitely test it first. :)
Update: Okay, the quick-correcting Ovid and lhoward point out the unbalanced problem. The only other thing I can think of is an alternation: (?:{([_a-zA-Z]\w*)}|([_a-zA-Z]\w*)) That part obviously goes after you've found the % sign. It will be more expensive, though. (The * operator hurts.)
In Section
Seekers of Perl Wisdom
|
|