Quick Start
Tutorial
Search & Replace
Tools & Languages
Examples
Reference
Regex Reference
Introduction
Table of Contents
Quick Reference
Characters
Basic Features
Character Classes
Shorthands
Anchors
Word Boundaries
Quantifiers
Capturing Groups & Backreferences
Named Groups & Backreferences
Special Groups
Unicode Characters and Properties
Unicode Versions
Unicode Categories
Unicode Scripts
Unicode Blocks
Unicode Binary Properties
Unicode Property Sets
Unicode Boundaries
Mode Modifiers
Recursion & Balancing Groups
Backtracking Control Verbs
Replacement Reference
Characters
Matched Text & Backreferences
Case Conversion
Context
Conditionals
More on This Site
Introduction
Regular Expressions Quick Start
Regular Expressions Tutorial
Replacement Strings Tutorial
Applications and Languages
Regular Expressions Examples
Regular Expressions Reference
Replacement Strings Reference
Book Reviews
Printable PDF
About This Site
RSS Feed & Blog
RegexBuddy—Better than a regular expression reference!

Regular Expression Reference: Shorthand Character Classes

FeatureSyntaxDescriptionExampleJGsoft Python JavaScript VBScript XRegExp .NET Java ICU RE2 Perl PCRE PCRE2 PHP Delphi R Ruby std::regex Boost Tcl POSIX GNU Oracle XML XPath
Shorthand Any shorthand outside character classes Shorthands can be used outside character classes. \w matches a single word character YESYESYESYESYESYESYESYESdefaultYESYESYESYESYESYESYESECMAECMA
extended
egrep
awk
YESn/aYESYESYESYES
Shorthand Any shorthand inside a character class Shorthands can be used inside character classes. [\w] matches a single word character YESYESYESYESYESYESYESYESdefaultYESYESYESYESYESYESYESECMAYESYESn/anonoYESYES
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 YESYESYESYESYESYESYESYESdefaultYESYESYESYESYESYESYESECMAYESerrorn/anonoYESYES
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 Unicode3.0 Unicode
2.4 ASCII
ASCIIASCIIASCIInon‑ECMA UnicodeASCIIUnicodedefault ASCIIUnicodeASCIIASCIIUnicodeASCIIASCIIASCIIECMA UnicodeUnicodeUnicodenonoUnicodeUnicodeUnicode
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 Unicode3.0 Unicode
2.4 ASCII
ASCIIASCIIASCIInon‑ECMA UnicodeASCIIUnicodedefault ASCIIUnicodeASCIIASCIIUnicodeASCIIASCIIASCIIECMA UnicodeUnicodeUnicodenoASCIIUnicodeUnicodeUnicode
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 Unicode3.0 Unicode
2.4 code page
UnicodeASCIIUnicodenon‑ECMA Unicode7 code page
4 ASCII
Unicodedefault ASCIIUnicode8.10 code page
4.5 ASCII
code pageUnicodeASCIIASCII2.0 code page
1.8 ASCII
ECMA UnicodeUnicodeUnicodenoASCIIUnicodeASCIIASCII
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. V2 UnicodenonononononononononononononononoUnicodenononononono
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 V2 Unicodenonononono8 UnicodeUnicodenoUnicode7.2 UnicodeUnicodeUnicodeUnicodeUnicodenonoECMA
1.42 Unicode
nononononono
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 V2 Unicodenonononono8 UnicodeUnicodenoUnicode7.2 UnicodeUnicodeUnicodeUnicodeUnicodenono1.42
Unicode
nononononono
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 nonononononononononononononono1.9 ASCIInononononononono
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 V2nononononononononononononononononononononoYESYES
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 V2nononononononononononononononononononononoYESYES
FeatureSyntaxDescriptionExampleJGsoft Python JavaScript VBScript XRegExp .NET Java ICU RE2 Perl PCRE PCRE2 PHP Delphi R Ruby std::regex Boost Tcl POSIX GNU Oracle XML XPath