Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Problem with regexp to match

by choroba (Cardinal)
on Oct 14, 2021 at 15:23 UTC ( [id://11137514]=note: print w/replies, xml ) Need Help??


in reply to Problem with regexp to match

In fact, you're interested in digits after a minus. Use the global matching to get all the matches:

#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; for my $string ('01/LC-13/E10GbE-1,01/LC-14/E10GbE-1', '01/LC-13/E10GbE-1' ) { my @numbers = $string =~ /-([0-9]+)/g; say "@numbers"; }
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

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

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

    No recent polls found