Regex Cheatsheet

A complete JavaScript regex reference — anchors, classes, quantifiers, groups, flags, and common patterns.

Anchors

PatternDescription
^Start of string (or line in multiline mode)
$End of string (or line in multiline mode)
\bWord boundary
\BNon-word boundary
\AStart of string (not supported in JS — use ^)
\ZEnd of string (not supported in JS — use $)

Character Classes

PatternDescription
.Any character except newline
\dDigit [0-9]
\DNon-digit [^0-9]
\wWord character [a-zA-Z0-9_]
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]Character set — matches a, b, or c
[^abc]Negated set — any character except a, b, or c
[a-z]Range — any lowercase letter
[\u0041-\u005A]Unicode range

Quantifiers

PatternDescription
*Zero or more (greedy)
+One or more (greedy)
?Zero or one (optional)
{n}Exactly n occurrences
{n,}n or more occurrences
{n,m}Between n and m occurrences
*?Zero or more (lazy)
+?One or more (lazy)
??Zero or one (lazy)

Groups & Lookarounds

PatternDescription
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
\1Backreference to group 1
\k<name>Named backreference
(?=abc)Positive lookahead — followed by
(?!abc)Negative lookahead — not followed by
(?<=abc)Positive lookbehind — preceded by
(?<!abc)Negative lookbehind — not preceded by
a|bAlternation — a or b

Flags

PatternDescription
gGlobal — find all matches (not just first)
iCase-insensitive matching
mMultiline — ^ and $ match line starts/ends
sDotall — . matches newlines too
uUnicode mode — enables full Unicode support
ySticky — match only from lastIndex position
dIndices — include match start/end indices

Escape Sequences

PatternDescription
\nNewline
\rCarriage return
\tTab character
\0Null character
\uXXXXUnicode escape (4 hex digits)
\u{XXXXX}Unicode escape (with u flag)
\xHHHex escape (2 hex digits)
\\Literal backslash
\.Literal dot

Common Patterns

PatternDescription
^[\w.-]+@[\w.-]+\.\w{2,}$Email address (basic)
https?:\/\/[\w\-._~:/?#[\]@!$&'()*+,;=%]+URL (http/https)
\b(?:\d{1,3}\.){3}\d{1,3}\bIPv4 address
^\d{4}-\d{2}-\d{2}$ISO date (YYYY-MM-DD)
^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$Hex color code
^\+?[1-9]\d{1,14}$International phone (E.164)
^[A-Z]{2}\d{2}[A-Z0-9]{4,}$IBAN (basic structure)
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$Strong password (8+ chars, upper, lower, digit)
^\d{5}(?:-\d{4})?$US ZIP code
[^\x00-\x7F]Non-ASCII characters
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$UUID v4
^\s+|\s+$Leading/trailing whitespace

FAQ

Is Regex Cheatsheet free to use?

Yes, Regex Cheatsheet is completely free to use on UtilityCove.

Does Regex Cheatsheet upload my data?

No. Regex Cheatsheet runs in your browser, so your input stays on your device.

Can I use Regex Cheatsheet on mobile?

Yes. Regex Cheatsheet works on modern mobile and desktop browsers.