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 |
Shorthand |
Any shorthand outside character classes |
Shorthands can be used outside character classes. |
\w matches a single word character |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA | ECMA extended egrep awk | YES | n/a | n/a | YES | YES | 10gR2 | YES | YES |
Shorthand |
Any shorthand inside a character class |
Shorthands can be used inside character classes. |
[\w] matches a single word character |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA | YES | YES | n/a | n/a | no | no | no | YES | YES |
Shorthand |
Any negated shorthand inside a character class |
Negated shorthands can be used inside character classes. |
[\W] matches a single character that is not a word character |
YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA | YES | error | n/a | n/a | no | no | no | YES | YES |
Shorthand |
\d |
Adds all digits to the character class. Matches a single digit if used outside character classes. |
[\d] and/or \d match a character that is a digit |
non‑ECMA Unicode | ASCII | Unicode | ASCII | ASCII | 5.3.4 Unicode 5.0.0 ASCII | ASCII | ASCII | ASCII | ASCII | ASCII | 3.0 Unicode 2.4 ASCII | ASCII | ECMA Unicode | Unicode | Unicode | no | no | no | no | 10gR2 Unicode | Unicode | Unicode |
Shorthand |
\w |
Adds all word characters to the character class. Matches a single word character if used outside character classes. |
[\w] and/or \w match any single word character |
non‑ECMA Unicode | ASCII | Unicode | ASCII | ASCII | 5.3.4 Unicode 5.0.0 code page | ASCII | ASCII | ASCII | ASCII | ASCII | 3.0 Unicode 2.4 ASCII | ASCII | ECMA Unicode | Unicode | Unicode | no | no | ASCII | ASCII | 10gR2 Unicode | Unicode | Unicode |
Shorthand |
\s |
Adds all whitespace to the character class. Matches a single whitespace character if used outside character classes. |
[\s] and/or \s match any single whitespace character |
non‑ECMA Unicode | ASCII | Unicode | ASCII | ASCII | 5.3.4 Unicode 5.0.0 code page | ASCII | ASCII | Unicode | ASCII | Unicode | 3.0 Unicode 2.4 ASCII | ASCII | ECMA Unicode | Unicode | Unicode | no | no | ASCII | ASCII | 10gR2 Unicode | ASCII | ASCII |
Shorthand |
\l and \u |
Adds all lowercase letters or all uppercase letters to the character class. Matches a single lowercase or uppercase letter if used outside character classes. |
\u\l matches Aa but not aA . |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | Unicode | no | no | no | no | no | no | no | no |
Shorthand |
\v |
Adds all vertical whitespace to the character class. Matches a single vertical whitespace character if used outside character classes. |
[\v] and/or \v match any single vertical whitespace character |
no | 8 Unicode | 5.10 Unicode | 7.2 Unicode | Unicode | 5.2.4 Unicode | Unicode | Unicode | no | no | no | no | no | no | ECMA 1.42–1.83 Unicode | no | no | no | no | no | no | no | no |
Shorthand |
\h |
Adds all horizontal whitespace to the character class. Matches a single horizontal whitespace character if used outside character classes. |
[\h] and/or \h match any single horizontal whitespace character |
no | 8 Unicode | 5.10 Unicode | 7.2 Unicode | Unicode | 5.2.4 Unicode | Unicode | Unicode | no | no | no | no | no | no | 1.42–1.83 Unicode | no | no | no | no | no | no | no | no |
Shorthand |
\h |
Adds all hexadecimal digits to the character class. Matches a hexadecimal digit if used outside character classes. |
[\h] and/or \h match any single hexadecimal digit |
no | no | no | no | no | no | no | no | no | no | no | no | 1.9 ASCII | no | no | no | no | no | no | no | no | no | no |
XML Shorthand |
\i |
Adds all characters that are allowed as the initial character in XML names to the character class. Matches one such character if used outside character classes. |
\i\c* matches an XML name |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | YES | YES |
XML Shorthand |
\c |
Adds all characters that are allowed as the second and following characters in XML names to the character class. Matches one such character if used outside character classes. |
\i\c* matches an XML name |
no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | YES | YES |
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 |
---|