\ (Escape character)
|Top Previous Next|
Escape character is used to suppress the special meaning of other special characters.
The expression 'Cost$' will match a string ending with 'Cost' whereas the expression 'Cost\$' will match a string that contains 'Cost$'. As you can see the escape character suppressed the special meaning of the '$' end of string character.
The expression 'file.txt' will match a string that contains 'file' followed by any character followed by 'txt, whereas the expression 'file\.txt' will match a string that contains 'file.txt'. This time the escape character suppressed the meaning of the special character '.' any character.
Finally, the expression to actually search for the '\' character is preceded with the '\', i.e. suppress the escape character, e.g. to search for '3\4' use the expression '3\\4'.