![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
Re: Regex a little less greedy pleaseby arturo (Vicar) |
on Mar 18, 2003 at 14:29 UTC ( #243988=note: print w/replies, xml ) | Need Help?? |
From perlre : If you want it to match the minimum number of times possible, follow the quantifier with a "?". Note that the meanings don’t change, just the "greediness" So, changing your regex to Should get you the behavior you want. If, however, you take to heart the lessons of Death to Dot Star!, you might want to write that this way: Avoiding using the post-match variable and using () to capture the stuff you want to get is left as an exercise for the reader =) HTH If not P, what? Q maybe?
In Section
Seekers of Perl Wisdom
|
|