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

Re: Problem with regexp to match

by choroba (Archbishop)
on Oct 14, 2021 at 15:23 UTC ( #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? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2022-05-22 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (79 votes). Check out past polls.

    Notices?