Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Regex not matching as expected

by AnomalousMonk (Archbishop)
on Nov 07, 2015 at 04:45 UTC ( [id://1147165]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex not matching as expected
in thread Regex not matching as expected

What about a bad 'N/A' with or without digits?

c:\@Work\Perl\monks>perl -wMstrict -e "for ( '1234 5678 no_nas_here blah blah', '1234 N/A should_be_na2 blah blah', 'N/A 5678 must_be_na1 blah blah', 'N/A N/A nana', 'foo 9999 fake_nas_1 blah', '9999 foo fake_nas_2 blah blah', 'foo foo fake_nas_3 blah blah blah', ) { my @flds = split; if ( $flds[0].$flds[1] eq 'N/AN/A' ) { print \"nana: $flds[2]\n\"; } elsif ( $flds[0] eq 'N/A' ) { print \"na1: $flds[2]\n\"; } elsif ( $flds[1] eq 'N/A' ) { print \"na2: $flds[2]\n\"; } else { print \"no na: $flds[2]\n\"; } } " no na: no_nas_here na2: should_be_na2 na1: must_be_na1 nana: nana no na: fake_nas_1 no na: fake_nas_2 no na: fake_nas_3


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://1147165]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-18 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found