Character Escapes 

Most of the important regular expression language operators are unescaped single characters. The escape character \ (a single backslash) signals to the regular expression parser that the character following the backslash is not an operator. For example, the parser treats an asterisk (*) as a repeating quantifier and a backslash followed by an asterisk (\*) as the Unicode character 002A.

The character escapes listed in this table are recognized both in regular expressions and in replacement patterns.

Escaped character Description

ordinary characters

Characters other than . $ ^ { [ ( | ) * + ? \ match themselves.


Matches a bell (alarm) \u0007.


Matches a backspace \u0008 if in a [] character class; otherwise, see the note following this table.


Matches a tab \u0009.


Matches a carriage return \u000D.


Matches a vertical tab \u000B.


Matches a form feed \u000C.


Matches a new line \u000A.


Matches an escape \u001B.


Matches an ASCII character as octal (up to three digits); numbers with no leading zero are backreferences if they have only one digit or if they correspond to a capturing group number. (For more information, see Backreferences.) For example, the character \040 represents a space.


Matches an ASCII character using hexadecimal representation (exactly two digits).


Matches an ASCII control character; for example, \cC is control-C.


Matches a Unicode character using hexadecimal representation (exactly four digits).


The Perl 5 character escape that is used to specify Unicode is not supported by the .NET Framework. The Perl 5 character escape is of the form \x{####…}, where "####…" is a series of hexadecimal digits. Instead, use the .NET Framework character escape described in this row.


When followed by a character that is not recognized as an escaped character, matches that character. For example, \* is the same as \x2A.


The escaped character \b is a special case. In a regular expression, \b denotes a word boundary (between \w and \W characters) except within a [] character class, where \b refers to the backspace character. In a replacement pattern, \b always denotes a backspace.