Do you know where your variables are? | |
PerlMonks |
Re: RE greedinessby Anonymous Monk |
on May 29, 2024 at 19:11 UTC ( [id://11159719]=note: print w/replies, xml ) | Need Help?? |
The (.*?) in your second attempt is a non-greedy match, which means it will match the smallest possible substring that satisfies the pattern. In this case, it matches an empty string because the optional (?:b=(\w))? can also match the empty string. Use a positive lookahead assertion to ensure that the (.*?) matches up to the optional b=(\w) part, but doesn't include it:
In Section
Seekers of Perl Wisdom
|
|