Opposite of regex match?

M

Marv

Hello,

How would you write 'does not match' in a regex match?

Below is what I was assuming would work, but it doesn't. I guess you
cannot use "!=~" for does not match. What can you use here?

#!/usr/bin/perl


$var1="test";

$var2 = "testing";

if ($var2 !=~ m/$var1/){

printf "Doesn't match\n";

} else {

printf "Does match\n";

}

Thanks,
Max
 
M

Matija Papec

X-Ftn-To: Marv

Marv said:
How would you write 'does not match' in a regex match?

Below is what I was assuming would work, but it doesn't. I guess you
cannot use "!=~" for does not match. What can you use here?

You were close,
!~
 
J

John W. Krahn

Marv said:
I was pulling my hair out on that one. Couldn't find the answer
anywhere.

perldoc perlop

perlop.pod has a description of all of perl's operators.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,815
Members
47,361
Latest member
RogerDuabe

Latest Threads

Top