Keep It Simple, Stupid | |
PerlMonks |
Re: Regex Optional capture doesn'tby LanX (Saint) |
on Oct 05, 2017 at 16:34 UTC ( [id://1200744]=note: print w/replies, xml ) | Need Help?? |
I think .+ is greedy and eats the rest of the string. But the regex is forced to backtrack if <(\w+TagIwant\b) is not optional otherwise it concludes happily. Changing to .+? should solve this.
UPDATEjust tested, not my day. declaring myself officially (mentally) ill.
UPDATEan elegant solution is buried at the end of this discussion here
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|