Regex Cheatsheet
Sections
5
categories
Tokens
44
total
Visible
44
all
Size
1.3 KB
reference
tokens · regex
Character classes
.\d\D\w\W\s\S[abc][^abc][a-z]\p{L}Anchors
^$\b\B\A\ZQuantifiers
*+?{n}{n,}{n,m}*?+???*+Groups & lookarounds
(...)(?:...)(?<name>...)\1\k<name>(?=...)(?!...)(?<=...)(?<!...)|Flags
gimsuydmeaning · description
Character classes
Any character (except newline unless s flag)
a.c → abc, axcDigit [0-9]
\d+ → 42Non-digit [^0-9]
Word char [A-Za-z0-9_]
Non-word char
Whitespace [ \t\n\r\f\v]
Non-whitespace
Any of a, b, c
Anything except a, b, c
Range a through z
Unicode letter (needs u flag)
Anchors
Start of string (or line with m flag)
End of string (or line with m flag)
Word boundary
Non-word boundary
Start of input (PCRE/Python; not JS)
End of input (PCRE/Python; not JS)
Quantifiers
0 or more, greedy
1 or more, greedy
0 or 1, greedy
Exactly n times
n or more times
n to m times
0 or more, lazy
1 or more, lazy
0 or 1, lazy
Possessive (no backtrack — not in JS)
Groups & lookarounds
Capturing group
Non-capturing group
Named capturing group
Backreference to group 1
Backreference to named group
Positive lookahead
Negative lookahead
Positive lookbehind
Negative lookbehind
Alternation
Flags
global — Find all matches, not just the first.
ignoreCase — Case-insensitive matching.
multiline — ^ and $ match at each line boundary.
dotAll — Dot . matches newlines too.
unicode — Treat pattern as Unicode; enable \p{...} properties.
sticky — Match only from lastIndex (no scanning ahead).
indices — Result includes per-group start/end indices.