Skip to main content

Advanced Regex Tester

Test regular expressions with full flag support (g, i, m, s, u, d), capture group inspection, real-time match highlighting, and preset patterns. Scroll down for a complete regex cheat sheet.

✓ 60K+ developers trust DevPlaybook ✓ Named capture groups ✓ All regex flags supported

Regex Cheat Sheet

Character Classes

. Any character except newline
\w Word character [a-zA-Z0-9_]
\d Digit [0-9]
\s Whitespace (space, tab, newline)
\W \D \S Negated versions of \w \d \s
[abc] Any of a, b, or c
[^abc] Not a, b, or c
[a-z] Character range a through z

Anchors

^ Start of string (or line in multiline mode)
$ End of string (or line in multiline mode)
\b Word boundary
\B Not a word boundary

Quantifiers

* 0 or more (greedy)
+ 1 or more (greedy)
? 0 or 1 (optional)
{n} Exactly n times
{n,} n or more times
{n,m} Between n and m times
*? +? ?? Lazy/non-greedy versions

Groups & Lookarounds

(abc) Capture group — accessible as $1, $2…
(?:abc) Non-capturing group — groups without capturing
(?<name>abc) Named capture group
(?=abc) Positive lookahead — followed by abc
(?!abc) Negative lookahead — not followed by abc
(?<=abc) Positive lookbehind — preceded by abc
(?<!abc) Negative lookbehind — not preceded by abc

Flags

g Global — find all matches, not just the first
i Case-insensitive matching
m Multiline — ^ and $ match each line
s Dotall — . matches newlines too
u Unicode — enables full Unicode matching
d Indices — include match start/end index in results

Frequently Asked Questions

What is a capture group in regex?▼

A capture group (abc) captures the matched substring so you can reference it later — in replace operations as $1 or backreferences as \1. Named groups (?<name>abc) let you reference by name with $<name> or \k<name>. Non-capturing groups (?:abc) group without capturing, useful for alternation or quantifier scope.

What is the difference between greedy and lazy quantifiers?▼

Greedy quantifiers (* + ?) match as much as possible. Lazy quantifiers (*? +? ??) match as little as possible. Example: <.+> on '<div><p></p></div>' — greedy matches the whole string, lazy matches just '<div>'. Use lazy when you want the shortest possible match.

When should I use a lookahead?▼

Use a lookahead (?=...) when you want to match only if followed by a pattern, without including that pattern in the match. Example: \d+(?= dollars) matches the number in '100 dollars' but not in '100 euros'. Negative lookahead (?!...) does the opposite.

What does the 'm' flag do?▼

The multiline flag makes ^ and $ match the start and end of each line (separated by \n), instead of only the start and end of the entire string. Without 'm', ^ only matches at position 0. With 'm', it matches after every newline too.

How do I match a literal dot or special character?▼

Escape special characters with a backslash: \. for a literal dot, \* for a literal asterisk, \( and \) for literal parentheses. Special regex characters that need escaping: . * + ? ^ $ { } [ ] | ( ) \

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Related Articles

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →