Matching operators
If the pattern in an instruction is just a regular expression, awk looks for a matching string anywhere in a record. Sometimes, however, you want to look for a matching string only in a particular field of a record. In this case, you can use a matching expression.
There are two types of matching expressions:
- string ~ /regular-expression/
- Is true if string matches the given regular expression. (The ~ character is called a tilde.)
- string !~ /regular-expression/
- Is true if string does not match the given regular expression.