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

Re: RE greediness

by Athanasius (Archbishop)
on Nov 03, 2016 at 09:02 UTC ( [id://1175211]=note: print w/replies, xml ) Need Help??


in reply to RE greedyness

Hello huck, and welcome to the Monastery!

But i still cant understand why the \d* in content2 was not greedy enough to capture all of the '39', instead taking the '9' to be NOT ';' .

Actually, that’s exactly what it did do — at first. But that didn’t lead to a match, because 39; doesn’t match \d*[^;]. So, as Corion says, the regex had to give up the last character and try again, giving 39, which does match. “Greedy” means as greedy as possible while still matching. This is explained in detail in the Camel Book (which I don’t have to hand) in a section called “The Little Engine That /Could(n’t)?/”

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

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

    No recent polls found