Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: a regex pattern how to understand

by hexcoder (Curate)
on Jul 09, 2015 at 08:21 UTC ( [id://1133910]=note: print w/replies, xml ) Need Help??


in reply to a regex pattern how to understand

Hello,

try this instead

while ( $text =~ m<Name:\s+([[:alpha:] ]+?)\s*Age:\s+(\d+)>g ) {

I changed the \s+Age part to \s*Age, since the space before 'Age' is already consumed by the previous construct, and so it is here not available anymore.

Replies are listed 'Best First'.
Re^2: a regex pattern how to understand
by Anonymous Monk on Jul 09, 2015 at 08:48 UTC
    the space before 'Age' is already consumed by the previous construct, and so it is here not available anymore.

    Sorry, but that's just plain incorrect. The code provided by the OP works just fine.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found