Feature | Syntax | Description | Example | .NET | Java | Perl | PCRE | PCRE2 | PHP | Delphi | R | JavaScript | VBScript | XRegExp | Python | Ruby | std::regex | Boost | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | Oracle | XML | XPath |
Literal character |
Any character except [\^$.|?*+() |
All characters except the listed special characters match a single instance of themselves |
a matches a |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES |
Literal curly braces |
{ and } |
{ and } are literal characters, unless they’re part of a valid regular expression token such as a quantifier {3} |
{ matches { |
YES | no | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | 1.9 | basic grep | ECMA 1.54–1.83 basic 1.38–1.83 grep 1.38–1.83 | YES | YES | YES | YES | no | YES | YES | no |
Backslash escapes a metacharacter |
\ followed by any of [\^$.|?*+(){} |
A backslash escapes special characters to suppress their special meaning |
\* matches * |
YES | no | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | 1.9 | basic grep | ECMA 1.54–1.83 basic 1.38–1.83 grep 1.38–1.83 | YES | YES | YES | YES | no | YES | YES | no |
Escape sequence |
\Q...\E |
Matches the characters between \Q and \E literally, suppressing the meaning of special characters |
\Q+-*/\E matches +-*/ |
no | YES | YES | YES | YES | YES | YES | YES | no | no | no | no | no | no | ECMA extended egrep awk | no | no | no | no | no | no | no | no |
Hexadecimal escape |
\xFF where FF are 2 hexadecimal digits |
Matches the character at the specified position in the code page |
\xA9 matches © when using the Latin-1 code page |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA | ECMA extended egrep awk | YES | string | string | string | string | no | no | no |
Character escape |
\n , \r and \t |
Match an LF character, CR character and a tab character respectively |
\r\n matches a Windows CRLF line break |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA awk | ECMA extended egrep awk | YES | string | string | string | string | no | YES | YES |
Line break |
\R |
Matches any line break, including CRLF as a pair, CR only, LF only, form feed, vertical tab, and any Unicode line break |
|
no | 8 | 5.10 | 7.0 | YES | 5.2.2 | YES | YES | no | no | no | no | 2.0 | no | ECMA 1.42–1.83 | no | no | no | no | no | no | no | no |
Line break |
\R |
Matches the next line control character U+0085 |
|
n/a | 8 | 5.10 | 7.0 | YES | 5.2.2 | YES | YES | n/a | n/a | n/a | n/a | 2.0 | n/a | ECMA 1.54–1.83 | n/a | n/a | n/a | n/a | n/a | n/a | n/a | n/a |
Line break |
\R |
CRLF line breaks are indivisible |
\R{2} and \R\R cannot match \r\n |
n/a | 9 no | 5.10 no | 7.0–8.12 no | YES | 5.2.2–5.3.18 no | XE–XE6 no | YES | n/a | n/a | n/a | n/a | YES | n/a | YES | n/a | n/a | n/a | n/a | n/a | n/a | n/a | n/a |
Line break |
Literal CRLF, LF, or CR line break |
Matches CRLF as a pair, CR only, and LF only regardless of the line break style used in the regex |
|
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | YES | YES |
Character escape |
\a |
Match the “alert” or “bell” control character (ASCII 0x07) |
|
YES | YES | YES | YES | YES | YES | YES | YES | no | no | no | YES | YES | awk | ECMA extended egrep awk | YES | no | no | no | no | no | no | no |
Character escape |
\b |
Match the “backspace” control character (ASCII 0x08) |
|
no | no | no | no | no | no | no | no | no | no | no | no | no | awk | no | YES | no | no | no | no | no | no | no |
Character escape |
\B |
Match a backslash |
\B matches \ |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | YES | no | no | no | no | no | no | no |
Character escape |
\e |
Match the “escape” control character (ASCII 0x1B) |
|
YES | YES | YES | YES | YES | YES | YES | YES | no | no | no | no | YES | no | ECMA extended egrep awk | YES | no | no | no | no | no | no | no |
Character escape |
\f |
Match the “form feed” control character (ASCII 0x0C) |
|
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA awk | ECMA extended egrep awk | YES | no | no | no | no | no | no | no |
Character escape |
\v |
Match the “vertical tab” control character (ASCII 0x0B), but not any other vertical whitespace. |
|
YES | 4–7 | no | no | no | no | no | no | YES | YES | YES | YES | YES | ECMA awk | ECMA 1.38–1.39 extended 1.38–1.83 egrep 1.38–1.83 awk 1.38–1.83 | YES | no | no | no | no | no | no | no |
Control character escape |
\cA through \cZ |
Match an ASCII character Control+A through Control+Z, equivalent to \x01 through \x1A |
\cM\cJ matches a Windows CRLF line break |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | no | YES | ECMA | ECMA extended egrep awk | YES | no | no | no | no | no | no | no |
Control character escape |
\ca through \cz |
Match an ASCII character Control+A through Control+Z, equivalent to \x01 through \x1A |
\cm\cj matches a Windows CRLF line break |
YES | no | YES | YES | YES | YES | YES | YES | YES | YES | YES | no | YES | ECMA | ECMA extended egrep awk | YES | no | no | no | no | no | no | no |
NULL escape |
\0 |
Match the NULL character |
|
YES | no | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA | YES | YES | no | no | no | no | no | no | no |
Octal escape |
\o{7777} where 7777 is any octal number |
Matches the character at the specified position in the active code page |
\o{20254} matches € when using Unicode |
no | no | 5.14 | 8.34 | YES | 5.5.10 | XE7 | 3.0.3 | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no |
Octal escape |
\1 through \7 |
Matches the character at the specified position in the ASCII table |
\7 matches the “bell” character |
ECMA | no | no | no | no | no | no | no | YES | YES | no | no | no | awk | no | no | no | no | no | no | no | no | no |
Octal escape |
\10 through \77 |
Matches the character at the specified position in the ASCII table |
\77 matches ? |
YES | no | YES | YES | YES | YES | YES | YES | YES | YES | no | no | YES | awk | no | YES | no | no | no | no | no | no | no |
Octal escape |
\100 through \177 |
Matches the character at the specified position in the ASCII table |
\100 matches @ |
YES | no | YES | YES | YES | YES | YES | YES | YES | YES | no | YES | YES | awk | no | YES | no | no | no | no | no | no | no |
Octal escape |
\200 through \377 |
Matches the character at the specified position in the active code page |
\377 matches ÿ when using the Latin-1 code page |
2.0–7.0 | no | YES | YES | YES | YES | YES | YES | YES | YES | no | YES | 1.8 only fail | awk | no | YES | no | no | no | no | no | no | no |
Octal escape |
\400 through \777 |
Matches the character at the specified position in the active code page |
\777 matches ǿ when using Unicode |
non‑ECMA 1.0–1.1 fail | no | 5.14 | 6.7 | YES | 5.2.0 | YES | YES | no | no | no | 3.5 error | 1.8 only fail | awk | no | 8.4–8.5 | no | no | no | no | no | no | no |
Octal escape |
\01 through \07 |
Matches the character at the specified position in the ASCII table |
\07 matches the “bell” character |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | no | YES | YES | awk | YES | YES | no | no | no | no | no | no | no |
Octal escape |
\010 through \077 |
Matches the character at the specified position in the ASCII table |
\077 matches ? |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | no | YES | YES | awk | YES | YES | no | no | no | no | no | no | no |
Octal escape |
\0100 through \0177 |
Matches the character at the specified position in the ASCII table |
\0100 matches @ |
no | YES | no | no | no | no | no | no | no | no | no | no | no | no | YES | no | no | no | no | no | no | no | no |
Octal escape |
\0200 through \0377 |
Matches the character at the specified position in the active code page |
\0377 matches ÿ when using the Latin-1 code page |
no | YES | no | no | no | no | no | no | no | no | no | no | no | no | YES | no | no | no | no | no | no | no | no |
Feature | Syntax | Description | Example | .NET | Java | Perl | PCRE | PCRE2 | PHP | Delphi | R | JavaScript | VBScript | XRegExp | Python | Ruby | std::regex | Boost | Tcl ARE | POSIX BRE | POSIX ERE | GNU BRE | GNU ERE | Oracle | XML | XPath |
---|