Draft
This page is not complete.
Character classes distinguish kinds of characters such as, for example, distinguishing between letters and digits.
Types
| Characters | Meaning |
|---|---|
. |
Has one of the following meanings:
Note that the ES2018 added the |
\d |
Matches any digit (Arabic numeral). Equivalent to |
\D |
Matches any character that is not a digit (Arabic numeral). Equivalent to |
\w |
Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to |
\W |
Matches any character that is not a word character from the basic Latin alphabet. Equivalent to |
\s |
Matches a single white space character, including space, tab, form feed, line feed and other Unicode spaces. Equivalent to |
\S |
Matches a single character other than white space. Equivalent to |
\t |
Matches a horizontal tab. |
\r |
Matches a carriage return. |
\n |
Matches a linefeed. |
\v |
Matches a vertical tab. |
\f |
Matches a form-feed. |
[\b] |
Matches a backspace. If you're looking for the word-boundary character (\b), see Boundaries. |
\0 |
Matches a NUL character. Do not follow this with another digit. |
\cX |
Where |
\xhh |
Matches the character with the code hh (two hexadecimal digits). |
\uhhhh |
Matches a UTF-16 code-unit with the value hhhh (four hexadecimal digits). |
\u{hhhh} or \u{hhhhh} |
(Only when u flag is set.) Matches the character with the Unicode value U+hhhh or U+hhhhh (hexadecimal digits). |
\ |
Indicates that the following character should be treated specially, or "escaped". It behaves one of two ways.
To match this character literally, escape it with itself. In other words to search for |
Examples
Browser support