Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Help with placing the matches of a regex into an Array

by JavaFan (Canon)
on Apr 28, 2012 at 20:47 UTC ( [id://967861]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Help with placing the matches of a regex into an Array
in thread Help with placing the matches of a regex into an Array

It depends on the data -- if the data is incorrectly formatted (a missing ' for instance), they may not do the same thing. And '.+?' has the tendency to be slower than '[^']+'. Usually, the more restrictive a pattern is, the faster: there's less opportunity to backtrack. There's much more commitment in '[^']+' then there is in '.+?': the former will always match two quotes in succession, and whatever is in between, regardless how the rest of the pattern looks like, but that's not the case with '.+?'; there's nothing stopping the .+? part to match quotes.

Replies are listed 'Best First'.
Re^4: Help with placing the matches of a regex into an Array
by stevieb (Canon) on Apr 28, 2012 at 20:57 UTC

    Thank you for your explanation. I'm still working on bettering my understanding of the look-ahead/backtrack aspects when working with Perl regexs. You've made it very clear to me here with this example.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-26 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found