![]() |
|
laziness, impatience, and hubris | |
PerlMonks |
Re: basic question: regular expressionby Ratazong (Monsignor) |
on Dec 01, 2016 at 07:34 UTC ( #1177016=note: print w/replies, xml ) | Need Help?? |
Hi! The reason is that * and ? also match zero times. So in your example 1, the regEx already matches the first k, which is followed by zero as. Even if a longer sequence comes later on in the string. If there is a match, the regEx tries to be as greedy as possible, that's why you get kkka in example 2. HTH, Rata
In Section
Seekers of Perl Wisdom
|
|