Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Print string next to pattern matching?

by AnomalousMonk (Archbishop)
on May 05, 2015 at 12:33 UTC ( [id://1125723]=note: print w/replies, xml ) Need Help??


in reply to Print string next to pattern matching?

Needs Perl version 5.10+ for  \K operator:

c:\@Work\Perl\monks>perl -wMstrict -le "use 5.010; ;; for my $s ( '2 INT_NET Net : c_c', '2 INT_NET Net : b_c', '2 INT_NET Net : a_c', ) { printf qq{'$s' -> }; my ($net_name) = $s =~ m{ : \s* \K \w+ }xmsg; print qq{'$net_name'}; } " '2 INT_NET Net : c_c' -> 'c_c' '2 INT_NET Net : b_c' -> 'b_c' '2 INT_NET Net : a_c' -> 'a_c'
Please see perlre, perlretut, perlrequick, and Perlmonks regex tutorials.


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://1125723]
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: (4)
As of 2024-04-19 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found