There's more than one way to do things | |
PerlMonks |
Re: basic question: regular expressionby Laurent_R (Canon) |
on Dec 01, 2016 at 08:51 UTC ( [id://1177024]=note: print w/replies, xml ) | Need Help?? |
The regex engine will not backtrack to find a "better" (i.e. longer) match; it will backtrack only as long as there no successful match. Greediness will apply only within the context of a given match.
In your two examples, the regex engine could find a successful match using the first "k" of your string. In such a case, it will simply report success and will not try anything to get a longer match by backtracking to the second "k".
In Section
Seekers of Perl Wisdom
|
|