Regex Cheatsheet
A complete JavaScript regex reference — anchors, classes, quantifiers, groups, flags, and common patterns.
Anchors
| Pattern | Description | |
|---|---|---|
^ | Start of string (or line in multiline mode) | |
$ | End of string (or line in multiline mode) | |
\b | Word boundary | |
\B | Non-word boundary | |
\A | Start of string (not supported in JS — use ^) | |
\Z | End of string (not supported in JS — use $) |
Character Classes
| Pattern | Description | |
|---|---|---|
. | Any character except newline | |
\d | Digit [0-9] | |
\D | Non-digit [^0-9] | |
\w | Word character [a-zA-Z0-9_] | |
\W | Non-word character | |
\s | Whitespace (space, tab, newline) | |
\S | Non-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
| Pattern | Description | |
|---|---|---|
* | 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
| Pattern | Description | |
|---|---|---|
(abc) | Capturing group | |
(?:abc) | Non-capturing group | |
(?<name>abc) | Named capturing group | |
\1 | Backreference 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|b | Alternation — a or b |
Flags
| Pattern | Description | |
|---|---|---|
g | Global — find all matches (not just first) | |
i | Case-insensitive matching | |
m | Multiline — ^ and $ match line starts/ends | |
s | Dotall — . matches newlines too | |
u | Unicode mode — enables full Unicode support | |
y | Sticky — match only from lastIndex position | |
d | Indices — include match start/end indices |
Escape Sequences
| Pattern | Description | |
|---|---|---|
\n | Newline | |
\r | Carriage return | |
\t | Tab character | |
\0 | Null character | |
\uXXXX | Unicode escape (4 hex digits) | |
\u{XXXXX} | Unicode escape (with u flag) | |
\xHH | Hex escape (2 hex digits) | |
\\ | Literal backslash | |
\. | Literal dot |
Common Patterns
| Pattern | Description | |
|---|---|---|
^[\w.-]+@[\w.-]+\.\w{2,}$ | Email address (basic) | |
https?:\/\/[\w\-._~:/?#[\]@!$&'()*+,;=%]+ | URL (http/https) | |
\b(?:\d{1,3}\.){3}\d{1,3}\b | IPv4 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.
More developer tools
Folder Structure Generator
Build folder structure diagrams, ASCII directory trees, and file tree visualizations for READMEs and docs.
.gitignore Generator
Generate merged .gitignore rules for your stack with one click.
JSON to TypeScript Interface
Convert JSON into TypeScript interfaces with inferred nested types.
Text to Slug Converter
Convert titles and phrases into clean SEO-friendly URL slugs.
UTM Builder
Build campaign URLs with UTM parameters for analytics tracking.
JSON Formatter & Validator
Validate, format, and minify JSON directly in your browser.