The character escapes listed in this table are recognized both in a regular expression and in a replacement pattern.
ordinary characters | Characters other than .$^{[(|)*+?\ are matched to themselves. |
\a | Matches a bell (alarm) \u0007. |
\b | Matches backspace \u0008 in [] character class; otherwise see below. |
\t | Matches a tab \u0009. |
\r | Matches a carriage return \u000A. |
\v | Matches a vertical tab \u000B. |
\f | Matches a form feed \u000C. |
\n | Matches a newline \u000D. |
\e | Matches an escape \u001B. |
\040 | Matches an ASCII character as octal (up to 3 digits); numbers with no leading 0 will be backreferences if they have only one digit or if they correspond to a capturing group number. (See Backreferences, below.) |
\x20 | Matches an ASCII character using hexadecimal (exactly two digits). |
\cC | Matches an ASCII control character, for example, \cC is control-C. |
\u0020 | Matches a Unicode character using hexadecimal (exactly four digits). |
\ | When followed by a character that is otherwise not recognized as an \ escape, matches that character. For example \* is the same as \x2A. |
The escape \b is a special case. Inside a regular expression, \b means word boundary (between \w and \W characters) except in a [] character class, where \b refers to the backspace character. In a replacement pattern, \b always means backspace.