How to Test Regex Online — Free Regex Tester with Live Match Highlighting
Test regular expressions against sample text with live match highlighting, capture groups, and flag support (g, i, m, s, u). Works with JavaScript, PCRE, and POSIX flavors.
Regex is write-only code
Most regex bugs come from writing a pattern that looks correct and never testing it against edge cases. A live tester fixes this: you see every match, every capture group, and every miss in real time. The regex tester highlights matches in the sample input and shows which part of the input each capture group consumed.
Flavors differ — pick the right one
| Flavor | Used by | Key differences |
|---|---|---|
| JavaScript (ECMAScript) | Browsers, Node.js, most linters | No lookbehind in older engines; no named refs in some |
| PCRE | PHP, nginx, most CLI tools | Full lookbehind, recursion, conditionals |
| POSIX ERE | grep -E, awk, sed -E | No lookaround; simpler syntax |
Python re | Python | PCRE-like but no recursion |
Go regexp | Go | RE2 — no backrefs, guaranteed linear time |
The flags
g— global (find every match, not just the first)i— case-insensitivem— multiline (^/$match start/end of each line)s— dotall (.matches newlines)u— Unicode (treats input as UTF-16 code points, enables\p{...})
Common patterns worth memorizing
- Email (simple):
[^\s@]+@[^\s@]+\.[^\s@]+— catches 99% of valid addresses - URL:
https?://\S+— trust but validate separately - Digits only:
^\d+$ - IPv4:
^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$ - UUID:
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ - Hex color:
^#([0-9a-f]{3}){1,2}$ - Leading/trailing whitespace:
^\s+|\s+$
Greedy vs lazy quantifiers
.* matches as much as possible. .*? matches as little as possible. The difference matters hugely: <.*> against <a>b</a> matches the whole string; <.*?> matches just <a>. HTML parsing bugs almost always involve picking the wrong one. (For real HTML, use a parser — regex is the wrong tool.)
When to stop using regex
If your pattern has more than three nested groups or more than one lookaround, you're probably reaching for the wrong tool. Parsing structured data (HTML, JSON, YAML) should use a parser. For complex text analysis, consider a tokenizer + state machine. For JSON-specific querying, use JSONPath tester.
Related tools
For comparing two strings' text (not regex), text compare. For diffing code, diff checker.
Featured Tools
Try these free tools directly in your browser — no sign-up required.
Regex Tester
Test and debug regular expressions in real time. Highlights matches, capture groups, and supports JavaScript regex flags for instant pattern validation.
Text Compare
Compare two blocks of text side by side and highlight the differences. Find added, removed, and changed lines instantly with color-coded diff.
Diff Checker
Compare two texts or code files side by side and highlight differences. Find added, removed, and changed lines instantly with colour-coded diff output.
JSONPath Tester
Test JSONPath expressions against JSON data instantly. Paste your JSON and a JSONPath query to see matched results highlighted in real time.