Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: RegEx Headaches

by kennethk (Abbot)
on Jun 19, 2013 at 19:16 UTC ( #1039832=note: print w/replies, xml ) Need Help??


in reply to Re^2: RegEx Headaches
in thread RegEx Headaches

The quantifier actually makes it match every group; however, it only stores the last match in $1, and thus that's what you see in your return. See Extracting matches in perlretut.

If you want to extract an arbitrary number of digits sandwiched between decimal points, you can grab them all, and then split the result.

/((?:\d+\.)+)/g; split /(?<=\.)/, $1;
Alternatively,
[i]n list context, //g returns a list of matched groupings, or if there are no groupings, a list of matches to the whole regexp
(see Global matching in perlretut) so you could try
my @res = /(?<=\.)\d+\./g;

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2023-03-28 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (66 votes). Check out past polls.

    Notices?