DEV/REF

Regex Cheatsheet

Searchable reference for regex tokens, quantifiers, groups, lookarounds, and flags.

Character classes
.Any char except newline
\dDigit [0-9]
\DNon-digit
\wWord char [A-Za-z0-9_]
\WNon-word char
\sWhitespace
\SNon-whitespace
[abc]Any of a, b, c
[^abc]None of a, b, c
[a-z]Range a to z
Anchors
^Start of string / line
$End of string / line
\bWord boundary
\BNon-word boundary
Quantifiers
*0 or more
+1 or more
?0 or 1
{n}Exactly n
{n,}n or more
{n,m}Between n and m
*?Lazy 0 or more
Groups
(abc)Capture group
(?:abc)Non-capturing group
(?<name>abc)Named group
a|ba or b
\1Backreference to group 1
Lookarounds
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind
Flags
gGlobal
iCase-insensitive
mMultiline
sDotall
uUnicode
ySticky

Related tools

All →