Regex cheatsheet
A regex cheatsheet covering characters, anchors, quantifiers, groups, lookarounds, and common patterns. Copy examples as needed.
Any character
.Digit
\dWord character
\wWhitespace
\sNot a digit
\DStart of string
^End of string
$Word boundary
\bNon-word boundary
\BZero or more
*One or more
+Zero or one
?Exactly n
{n}Between n and m
{n,m}Lazy match
*?Capturing group
(...)Non-capturing group
(?:...)Named group
(?<name>...)Backreference
\1Alternation
a|bPositive lookahead
(?=...)Negative lookahead
(?!...)Positive lookbehind
(?<=...)Negative lookbehind
(?<!...)// About this tool
Look up regex syntax without searching through documentation. Browse categories and copy the expression or pattern you need into your code. Each entry includes a short description.
// How to use it
- Find the syntax category you need.
- Review the expression and description.
- Copy the pattern into your code.
// Frequently asked questions
Which regex flavor is this for?
The examples follow common JavaScript/PCRE-style syntax; some engines differ in details.
Does it test patterns?
No. Use the regex tester tool to run a pattern against sample text.