Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Quick Regex question

by AppleFritter (Vicar)
on Oct 29, 2015 at 22:02 UTC ( [id://1146405]=note: print w/replies, xml ) Need Help??


in reply to Quick Regex question

Howdy, welcome back to the Monastery!

Use capturing. Also take advantage of the fact the m// operator returns captures ($1, $2 etc.) in list context, and observe you don't need square brackets around \d:

my $text = "Signal\nLTE-FDD 4; Channel 2175"; my ($band, $channel) = ($text =~ /Signal\nLTE-FDD (\d{1,2}); Channel ( +\d{3,4})/i); print "$band\t$channel\n";

More on capturing groups can be found in perlre#Capture groups.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-03-19 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found