Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: basic question: regular expression

by Laurent_R (Canon)
on Dec 01, 2016 at 08:51 UTC ( [id://1177024]=note: print w/replies, xml ) Need Help??


in reply to basic question: regular expression

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".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1177024]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-24 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found