Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^11: Understanding a portion of perlretut

by Athanasius (Archbishop)
on Dec 10, 2015 at 13:27 UTC ( [id://1149893]=note: print w/replies, xml ) Need Help??


in reply to Re^10: Understanding a portion of perlretut
in thread Understanding a portion on the Perlretut

Yes, thanks, I’m starting to see some light. :-) But:

In the first case, the engine starts from the left and finds a match, repeating (\w\w\w) 3 times:

Makes sense, but then, if the $1 match effectively ends up as (\w\w\w){3}, shouldn’t $1 contain uvXYZdabc? Or, conversely, if the ? quantifier following the * causes it to find the minimum string in uvXYZdabc matching (\w\w\w)*, shouldn’t that be "", the null string? Why does $1 match abc here?

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

Replies are listed 'Best First'.
Re^12: Understanding a portion of perlretut
by Corion (Patriarch) on Dec 10, 2015 at 13:30 UTC

    The repeated capturing overwrites the value in $1. If you want the repetition inside of a capture variable, you'll have to use something like ((?:\w\w\w)*?).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-25 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found