Skip to content

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
  • 100% free — no account needed
  • Runs in your browser
  • Nothing is uploaded

Frequently asked questions

Is Regex Cheatsheet really free?

Yes. Regex Cheatsheet is completely free on PureBrowser — every feature, with no account, no trial, and no credit card.

Does Regex Cheatsheet upload my data?

No. Regex Cheatsheet runs entirely inside your browser, so anything you type, paste, or open stays on your own device.

Do I need to sign up or install anything?

Neither. There is no account and nothing to download — open the page and Regex Cheatsheet is ready to use on desktop or mobile.

Does Regex Cheatsheet work offline?

Once the page has loaded, yes. All of the processing happens locally in your browser, so it keeps working without a connection.