Searchable JavaScript regex syntax reference, grouped by category
.Any character except a line break
a.c → abc
\dA digit 0–9
\d+ → 2026
\DAnything that is not a digit
\wLetter, digit or underscore
\w+
\WAnything that is not a word character
\sWhitespace: space, tab, line break
\SAnything that is not whitespace
[abc]One of the characters in the set
[aeiou]
[^abc]Any character not in the set
[a-z]A range of characters
[A-Z0-9]
\p{L}A Unicode property (needs the u flag)
\p{Script=Han}
\P{L}Anything outside that Unicode property
\P{L}+
*The previous item zero or more times
+The previous item one or more times
?The previous item zero or one time
{n}Exactly n times
\d{4}
{n,}At least n times
{n,m}Between n and m times
*?Add ? to any quantifier to make it lazy, matching as little as possible
<.+?>
^Start of input (or of a line with the m flag)
$End of input (or of a line with the m flag)
\bA word boundary
\bcat\b
\BNot a word boundary
(abc)Capturing group, usable as $1 or \1
(\d{4})-(\d{2})
(?:abc)Non-capturing group: groups without storing
(?<name>abc)Named capturing group
(?<year>\d{4})
a|bAlternation: match either side
cat|dog
\1 \2Backreference to an earlier group
(\w)\1
\k<name>Backreference to a named group
(?=abc)Positive lookahead: what follows must match
\d+(?= 元)
(?!abc)Negative lookahead: what follows must not match
(?<=abc)Positive lookbehind: what precedes must match
(?<=\$)\d+
(?<!abc)Negative lookbehind: what precedes must not match
\nLine feed
\tTab
\rCarriage return
\fForm feed
\vVertical tab
\0The NUL character
\cXA control character, e.g. \cJ for line feed
\\A literal backslash
\.Escape a metacharacter, e.g. a literal dot
\u4E2DMatch one character by code point
\u{1F600}Code point above U+FFFF, needs the u flag
\u{1F600}
\x41Match one character by hex code
gGlobal: find every match
iCase-insensitive
mMultiline: ^ and $ match line boundaries
sDot matches line breaks too
uTreat the pattern as Unicode
vUnicode sets: adds set operations, cannot be combined with u
[\p{L}--[aeiou]]
ySticky: match only at the current position
dRecord match indices
Based on JavaScript (ECMAScript) regular expressions. Lookbehind, \p{...} and the v flag need a reasonably recent browser. Use the copy button to grab a snippet.