Regex Tester
Test a regular expression against a string with live match highlighting.
About Regex Tester
Tests a regular expression against a sample string, highlighting matches and capture groups directly against the input so you can see exactly what a pattern does and doesn't catch without running actual code. Regex is notoriously easy to write almost right — a pattern that matches the three examples you tried by hand but fails on the fourth edge case in production. Worth testing both strings that should match and strings that specifically shouldn't, since a pattern that's too permissive is just as much a bug as one that's too strict.
Regex syntax isn't fully identical across languages and engines — a lookbehind or named capture group that works here may need adjusting for a different language's regex implementation, since not every engine supports every feature.
Quick Reference
? 0 or 1 {n,m} range
[abc] class [^abc] not
^ start $ end
\d digit \w word \s space
(…) group (?:…) non-cap
a|b or \b word boundary
Flags: g=global i=case m=multiline s=dotall
Which regex flavor this is
Patterns run in your browser's JavaScript engine (ECMAScript). Supported flags: g global (always on here so every match is shown), i ignore case, m multiline (^/$ match at line breaks), s dotall (. matches newlines), u Unicode, y sticky.
Differences from other engines
| Feature | JavaScript | Elsewhere |
|---|---|---|
| Named group | (?<name>…) | Python also accepts (?P<name>…) |
| Lookbehind | Supported, any length | PCRE and Python: fixed length only |
| Start/end of input | ^ $ without m | \A and \z in PCRE and Ruby, \Z in Python |
Possessive a++, atomic (?>…) | Not supported | PCRE, Java |
POSIX classes [[:digit:]] | Not supported | grep, sed, PCRE |
For grep use grep -E (extended) or grep -P (PCRE, GNU only); plain grep needs \+ and \|.
Common mistakes
- Unescaped dot:
example.comalso matchesexampleXcom. Writeexample\.com. - Greedy matching:
".*"on"a" and "b"matches the whole line. Use".*?"or"[^"]*". - Missing anchors:
\d{3}also matches inside12345. Use^\d{3}$or\b\d{3}\b. - Catastrophic backtracking: nested quantifiers such as
(a+)+$can take exponential time on a non-matching input and freeze the page or your server (ReDoS).
Useful patterns for admins
- IPv4 (loose):
\b(?:\d{1,3}\.){3}\d{1,3}\b - Email address in a log line (loose):
[\w.+-]+@[\w-]+(\.[\w-]+)+ - HTTP status in an access log:
" (\d{3})
Testing runs entirely in your browser.