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

Re: regular expression inverse match NOT match?

by Athanasius (Monsignor)
on Sep 25, 2013 at 02:02 UTC ( #1055589=note: print w/ replies, xml ) Need Help??


in reply to regular expression inverse match NOT match?

There are two ways to do this. The first is to use an ordinary match and then negate the result:

if (!($string =~ /keyword/)) { print "match failed"; }

or:

unless ($string =~ /keyword/) { print "match failed"; }

The second is to use the negated binding operator !~:

if ($string !~ /keyword/) { print "match failed"; }

See perlop#Binding-Operators.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re: regular expression inverse match NOT match?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-11-23 07:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (129 votes), past polls