About
The escape character in a regular expression is the backslash.
It's needed when the regular expression want to design a meta characters in a regular expression.
It
- takes away any special meaning that the meta characters may have.
- applies both inside and outside character classes.
Articles Related
Example
For example, if you want to match:
- the backslash itself, you write \\
- a * character, you write \*
otherwise, they would be have be interpreted as meta-character
Php: Single and double quoted PHP strings have special meaning of backslash. Thus if \ has to be matched with a regular expression \\, then “\\\\” or '\\\\' must be used in PHP code.