Reference

Click any code snippet to copy it.

Character Classes

.Any character (except newline)
\wWord char (a-z, A-Z, 0-9, _)
\dDigit (0-9)
\sWhitespace (space, tab, newline)
\WNot a word char
\DNot a digit
\SNot whitespace

Unicode Properties

\p{L}Any Unicode letter (requires u flag)
\p{N}Any Unicode number (requires u flag)
\p{P}Any Unicode punctuation (requires u flag)
\p{S}Any Unicode symbol (requires u flag)
\p{Z}Any Unicode separator (requires u flag)
\p{M}Any Unicode mark (requires u flag)
\P{L}Not a Unicode letter (requires u flag)

Anchors

^Start of string/line
$End of string/line
\bWord boundary
\BNon-word boundary

Quantifiers

*0 or more
+1 or more
?0 or 1 (Optional)
{3}Exactly 3 times
{3,}3 or more times
{3,6}Between 3 and 6 times

Groups & Lookaround

(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
(?=abc)Positive Lookahead: match if followed by
(?!abc)Negative Lookahead: match if NOT followed by
(?<=abc)Positive Lookbehind: match if preceded by
(?<!abc)Negative Lookbehind: match if NOT preceded by

Flags

gGlobal match
iIgnore case
mMultiline
sDot All (dot matches newline)