Regex Tester
Result
Share on Social Media:
Regex Tester — Debug Regular Expressions in Real Time
Regular expressions are the most powerful text-processing tool in programming — and the easiest to get subtly wrong. This free regex tester highlights every match live as you type, lists capture groups per match, and supports the full JavaScript flag set (g, i, m, s, u, y), so you can iterate on a pattern in seconds instead of re-running a script twenty times. Everything executes locally in your browser: fast, private, and free with no signup.
Regex Syntax Quick Reference
| Token | Matches |
|---|---|
| \d / \D | digit / non-digit |
| \w / \W | word character [a-zA-Z0-9_] / non-word |
| \s / \S | whitespace / non-whitespace |
| . | any character except newline |
| ^ $ | start / end of string (or line with m flag) |
| * + ? | 0+, 1+, 0 or 1 repetitions |
| {2,5} | between 2 and 5 repetitions |
| [abc] [^abc] | character set / negated set |
| (x) (?:x) | capture group / non-capturing group |
| a|b | alternation — a or b |
| \b | word boundary |
| (?=x) (?!x) | lookahead / negative lookahead |
Battle-Tested Patterns You Can Copy
- Email (practical):
[\w.+-]+@[\w-]+\.[\w.-]+ - URL:
https?:\/\/[^\s]+ - ISO date:
\d{4}-\d{2}-\d{2} - US phone:
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4} - IPv4 address:
\b(?:\d{1,3}\.){3}\d{1,3}\b - Hex color:
#(?:[0-9a-fA-F]{3}){1,2}\b - Trim whitespace: find
^\s+|\s+$, replace with nothing
The Three Bugs That Cause 90% of Regex Failures
1. Greedy quantifiers. <.*> against <b>bold</b> matches the entire string, not just the first tag. Fix: <.*?> (lazy) or <[^>]*> (negated set — usually faster).
2. Unescaped metacharacters. A literal dot, plus, or parenthesis must be escaped: matching "3.14" requires 3\.14, otherwise the dot matches any character and "3X14" passes too.
3. Missing anchors in validation. \d{4} happily matches inside "abc12345xyz". For full-string validation, anchor it: ^\d{4}$.
Performance Tip: Catastrophic Backtracking
Nested quantifiers like (a+)+$ can hang an engine when a near-match fails, forcing exponential backtracking. If a pattern freezes on long input, replace nested quantifiers with atomic constructs or negated character classes. Testing patterns here first — against realistic input sizes — catches these traps before they reach production.
Free, Instant, Private
No account, no rate limits, no data leaves your machine. Bookmark it as your regex scratchpad for every language — the core syntax above is identical across JavaScript, Python, PHP, Java, and Go, with only minor flavor differences.