Regex Tester
Test regex matches live and inspect every capture group
What is Regex Tester?
A regex tester runs your pattern against sample text as you type, highlighting each match and listing the position and content of every capture group, with support for the g, i, m, s, and u flags. Matching uses the browser native regular expression engine, so your test text is never uploaded.
How to use Regex Tester
- 1Enter your regular expression — you do not need the surrounding slashes.
- 2Tick the flags you need; check g for global matching.
- 3Paste sample content into the test text box and matches highlight instantly.
- 4Check the group list underneath to confirm the captured text and indexes are what you expect.
How do I do this in code?
Use the tool above for one-off work; for anything you repeat, move it into a script or your project.
const re = /(\d{4})-(\d{2})-(\d{2})/g;
for (const m of text.matchAll(re)) {
console.log(m[0], m[1], m[2], m[3], m.index);
}Common errors and how to fix them
| Symptom | Cause | Fix |
|---|---|---|
| Only the first match is found | The g flag is not set, and a regex returns just the first match by default. | Tick the g flag, which corresponds to the /g at the end of a literal in code. |
| . does not match newlines | By default the dot does not match line-break characters. | Tick the s (dotAll) flag, or use [\s\S] instead. |
| The page freezes or matching is extremely slow | Nested quantifiers cause catastrophic backtracking; (a+)+b is the classic example. | Avoid nested quantifiers — rewrite the pattern into something more deterministic or add boundary anchors. |
Frequently asked questions
Is this regex syntax the same as Python or Java?+
Not entirely. This tool uses the JavaScript regex engine, which differs from Python, Java, and PCRE in named-group syntax, lookbehind support, and some escaping details. When you move a pattern you tuned here into another language, verify it once more in that language.
Why does my regex match here but not on my backend?+
Three causes cover most cases: the backend uses a different regex engine; the pattern was escaped one extra time in transit (\d became \\d); or the flags were not set to the same values. Start by printing the exact pattern string the backend actually received.
Related tools
All toolsText Diff Checker
Compare two blocks of text line by line, optionally ignoring whitespace
JSON Diff
Compare two JSON documents structurally, by key path
Case Converter
Convert identifiers between camelCase, snake_case, kebab-case, and more
Word Counter
Count words, characters, lines, and estimated reading time
AI Token Counter
Count AI tokens and estimate what a call will cost
Remove Duplicate Lines
Remove duplicate lines, optionally ignoring case and whitespace