|This article needs additional citations for verification. (May 2013)|
In regular expressions, there are 11 metacharacters that must always be preceded by a backslash, \, to be used inside of the expression:
The opening square bracket [, the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening round bracket ( and the closing round bracket ).
If you want to use any of these characters as a literal in a regex, you need to escape them with a backslash. If you want to match 1+1=2, the correct regex is 1\+1=2. Otherwise, the plus sign will have a special meaning.
- In some Unix shells and Windows PowerShell, the ; (semicolon) character is a statement separator.
- In many regular expression engines, the . (dot) character matches any character, not just a dot.
- In XML and HTML, the & (ampersand) character introduces an HTML entity.
- In many programming languages, strings are delimited using quotes. In some cases, escape characters (and other methods) are used to avoid delimiter collision. Example : "He said : \"Hello\"".
|This programming language–related article is a stub. You can help Wikipedia by expanding it.|