Search code examples
regexpattern-matchingopensips

regex match equal with tilde Vs double equal sign


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()
}

Solution

  • =~ - 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"