Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Complex regex question

by AnomalousMonk (Archbishop)
on Sep 25, 2019 at 06:47 UTC ( [id://11106668]=note: print w/replies, xml ) Need Help??


in reply to Complex regex question

And of course, the other approach (if you don't have 5.10+) is to just grep away all undefined values:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $s = 'foo [21a] plus (b23) baz'; ;; my @captures = grep defined, $s =~ m{ (\d+) (a|b) | (a|b) (\d+) }xmsg ; dd \@captures; " [21, "a", "b", 23]


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-18 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found