Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: help with lazy matching

by Special_K (Monk)
on Jan 05, 2015 at 23:07 UTC ( [id://1112252]=note: print w/replies, xml ) Need Help??


in reply to Re^3: help with lazy matching
in thread help with lazy matching

I think the source of my confusion was not knowing that regular expressions in perl always start matching from the left side. If the regular expression could start matching from anywhere, then using the non-greedy modifier could give the behavior I was expecting in my original post, i.e. matching "bar".

Replies are listed 'Best First'.
Re^5: help with lazy matching
by davido (Cardinal) on Jan 05, 2015 at 23:51 UTC

    This is not a Perl-specific issue. The "Leftmost" rule is one of the features of a NFA-based regular expression engine, which includes Perl, PHP, Python, and most other commonly used regular expression implementations. So now that you're aware of it with respect to Perl, you've learned something that can be applied to most other languages that implement regexes as well! :)


    Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found