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.