Visual Reference
/delimiter^start anchor(group open\wword char@literal @[\w-]char class+one or more\.literal dot[a-z]char range{2,}2 or more$end anchor/delimitergiflags
Hover any token above to see what it does. Every piece of a regular expression explained visually.
01 — Structure
Type any regex below — get it decoded piece by piece in plain English.
regex decoder — type any pattern to decode it //
^Start of string — anchor
[\w.+-]Character class: [\w.+-] — charclass
+1 or more (greedy) — quantifier
[\w-]Character class: [\w-] — charclass
+1 or more (greedy) — quantifier
\.Escaped literal "." — escape
[a-zA-Z]Character class: [a-zA-Z] — charclass
{2,}2 or more (greedy) — quantifier
/iCase-insensitive — flag
02 — Interactive
Write a pattern, write test strings — see matches highlighted in real time.
live tester — matches highlight as you type test string
matches6pattern/\b\w+ing\b/gi
matches highlighted
She was running quickly, jumping over the flowing river, singing and dancing under the morning sky.
captured groups
no capture groups
03 — Building Blocks
Every token category — click any token to load it into the tester.
Anchors
^start of string/line^Hello
$end of string/lineworld$
\bword boundary\bcat\b
Character Escapes
\ddigit [0-9]\d{3}
\wword char [a-zA-Z0-9_]\w+
\swhitespace\s+
.any char except newlinea.c
Character Classes
[abc]any of a, b, c[aeiou]
[^abc]not a, b, or c[^0-9]
[a-z]char range a to z[a-f0-9]
Quantifiers
*0 or more (greedy)\d*
+1 or more (greedy)\w+
?0 or 1 (optional)colou?r
{n}exactly n times\d{4}
*?lazy (as few as possible)<.+?>
Groups & Alternation
(abc)capturing group(\d+)
(?:)non-capturing group(?:\d+)
a|balternation (or)cat|dog
Lookaround
(?=)positive lookahead\d(?= px)
(?!)negative lookahead\d(?! px)
04 — Quantifiers Deep Dive
Greedy takes as much as possible. Lazy takes as little as possible.
greedy — .+ matches as much as possible
Pattern: <.+> — 1 match (whole thing)
lazy — .+? matches as little as possible
Pattern: <.+?> — 4 matches (each tag)
05 — Real World
Common real-world patterns, broken down token by token. Edit the test string to see matches live.
Email Pattern
/^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$/i
test strings
user@example.com
bad-email@ no match
test.user+tag@company.co.uk no match
hello@world.org
06 — Modifiers
Flags change how the entire pattern behaves — global, case-insensitive, multiline, and more.
gglobal
Find all matches rather than stopping after the first.
without /g: /cat/
the cat sat on a cat mat
with /g: /cat/g
the cat sat on a cat mat
icase-insensitive
Match regardless of upper/lower case.
without /i: /hello/
Hello World hello
with /i: /hello/gi
Hello World hello
mmultiline
Makes ^ match start of each line and $ match end of each line.
without /m: /^\w+/
line one
line two
with /m: /^\w+/gm
line one
line two
sdot-all
Makes dot (.) match newline characters too.
without /s: /a.b/
a
b — a b
with /s: /a.b/gs
a
b — a b
07 — Zero-Width Assertions
These check what's around a match without consuming characters.
(?=...)Positive Lookahead
Match X only if followed by Y. Y is not included in the match.
\d+(?= dollars)
50← matched (followed by " dollars")
30← no match ("euros" not "dollars")
(?!...)Negative Lookahead
Match X only if NOT followed by Y.
\d+(?! dollars)
50← no match (IS followed by "dollars")
30← matched (NOT followed by "dollars")
(?<=...)Positive Lookbehind
Match X only if preceded by Y.
(?<=\$)\d+
100← matched (preceded by $)
(?<!...)Negative Lookbehind
Match X only if NOT preceded by Y.
(?<!\$)\d+
50← matched (NOT preceded by $)
08 — Quick Reference
Everything in one place.
Anchors
| ^ | Start of string | ^Hello |
| $ | End of string | \d$ |
| \b | Word boundary | \bword\b |
Character Classes
| [abc] | Any of a,b,c | [aeiou] |
| [^abc] | Not a,b,c | [^0-9] |
| [a-z] | Range a–z | [a-zA-Z] |
Shorthand Escapes
| \d | Digit [0-9] | \d{4} |
| \w | Word char | \w+ |
| \s | Whitespace | \s+ |
Quantifiers
| * | 0 or more | \d* |
| + | 1 or more | \w+ |
| ? | 0 or 1 | colou?r |
| {n} | Exactly n | \d{4} |
| {n,m} | n to m | \d{3,5} |
| *? | 0+ lazy | .*? |
Groups
| (abc) | Capturing group | (\d+) |
| (?:abc) | Non-capturing | (?:\d+) |
| (?=) | Positive lookahead | \d(?= px) |
| (?!) | Negative lookahead | \d(?! px) |
Flags
| g | Global — all matches | /cat/g |
| i | Case-insensitive | /hello/i |
| m | Multiline ^ and $ | /^\w/gm |
| s | Dot matches newlines | /a.b/s |
Special Characters
| . | Any char except newline | a.c |
| | | Alternation (or) | cat|dog |
| \n | Newline | \r\n |
Common Patterns
| Email | ^[\w.+-]+@[\w-]+\.[a-z]{2,}$ | i flag |
| Slug | [a-z0-9-]+ | g flag |
| UUID | [a-f0-9-]{36} | i flag |