A complete JavaScript regex reference — anchors, classes, quantifiers, groups, flags, and common patterns.
| 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 $) |
| 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 |
| 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) |
| 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 |
| 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 |
| 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 |
| 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 |
Yes, Regex Cheatsheet is completely free to use on UtilityCove.
No. Regex Cheatsheet runs in your browser, so your input stays on your device.
Yes. Regex Cheatsheet works on modern mobile and desktop browsers.
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.