Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: regex for multiple capture within boundary

by ikegami (Patriarch)
on Jul 17, 2006 at 01:28 UTC ( [id://561627]=note: print w/replies, xml ) Need Help??


in reply to Re^2: regex for multiple capture within boundary
in thread regex for multiple capture within boundary

That's exactly it (although there could be 0 elements if the match fails).

my @nums = ($x =~ /\s(\S+)/)[0] =~ /(\d+)/g;
could also be written as
my @nums = ($x =~ /\s(\S+)/ ? $1 : undef) =~ /(\d+)/g;

If you're going to use /g, drop the \s:

# @nums = ('3', '33'); my $word = 2; my @nums = ($x =~ /(\S+)/g)[$word] =~ /(\d+)/g;

or use split:

# @nums = ('3', '33'); my $word = 2; my @nums = (split(' ', $x))[$word] =~ /(\d+)/g;

Log In?
Username:
Password:

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

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

    No recent polls found