regex match equal with tilde Vs double equal sign

819 views Asked by At

Its wired question but i want to know what is the difference between =~ and ==

Following "string" i am trying to find.

if($ua =~ "friendly-scanner") {
  drop()
}

Vs

if($ua == "friendly-scanner") {
  drop()
}
1

There are 1 answers

0
nitishagar On BEST ANSWER
=~ - Does a regular expression matching
== - Compares two for equality

For example:

if($ua =~ "^friendly") is "$ua begins with friendly"
if($ua == "friendly") is "$ua exact match with friendly"