![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Perl's regex engine causes me distressby japhy (Canon) |
on Sep 21, 2000 at 23:04 UTC ( [id://33542]=perlquestion: print w/replies, xml ) | Need Help?? |
japhy has asked for the wisdom of the Perl Monks concerning the following question:
Here is my string: "A1234567890A". Here is my
regex:
Now, before you ask, this is related to a) unrolling the loop, and b) reversing a regex. But it's also a very isolated case of the regex engine being a ninny. This what I personally think the regex engine should do: At this point, Perl should NOT try to do: since Perl should KNOW that '0' was matched by [^AB]*, so it can't POSSIBLY match B. Instead, Perl should realize it should give up, and continue: This is NOT the case. Perl zips ALL the way back to the first 0 in the string, trying to match .B until it is exhausted, and goes back to the '...890' having been matched by [^AB]*, and it goes to the [^AB]* outside the (?:...)*. This matches nothing, and then the 'A' matches. My gripe is that Perl should know that if something COULD be matched by [^AB]*, then it CAN'T match 'B'. $_="goto+F.print+chop;\n=yhpaj";F1:eval
Back to
Seekers of Perl Wisdom
|
|