Skip to content
Visual Reference

Regex Explorer

/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

Regex Anatomy & Decoder

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
@
Literal "@" — literal
[\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
$
End of string — anchor
/i
Case-insensitive — flag
02 — Interactive

Live Regex Tester

Write a pattern, write test strings — see matches highlighted in real time.

live tester — matches highlight as you type
pattern
//
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

Token Reference

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 vs Lazy

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)
quantifier overview
*0 or more
a
a
…
+1 or more
a
a
…
?0 or 1
a
{3}exactly 3
a
a
a
{2,4}2 to 4
a
a
a
a
05 — Real World

Pattern Lab

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

token breakdown

^
Start
[\w.+-]+
Local part
@
Literal @
[\w-]+
Domain
\.
Literal dot
[a-zA-Z]{2,}
TLD
$
End

test strings

user@example.com
bad-email@ no match
test.user+tag@company.co.uk no match
hello@world.org
06 — Modifiers

Regex Flags

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

Lookaheads & Lookbehinds

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

Cheatsheet

Everything in one place.

Anchors
^Start of string^Hello
$End of string\d$
\bWord 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
\dDigit [0-9]\d{4}
\wWord char\w+
\sWhitespace\s+
Quantifiers
*0 or more\d*
+1 or more\w+
?0 or 1colou?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
gGlobal — all matches/cat/g
iCase-insensitive/hello/i
mMultiline ^ and $/^\w/gm
sDot matches newlines/a.b/s
Special Characters
.Any char except newlinea.c
|Alternation (or)cat|dog
\nNewline\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