Regex tester
Test JavaScript patterns against sample text.
Your result will appear here.
Enter your input, then run the tool.How to use the regex tester
Try a JavaScript regular expression against text and see each match, its position and capture groups.
Enter sample text, put the pattern in the separate field without slash delimiters, choose flags and run the test.
- Paste the text to search into Input.
- Type the pattern in “Pattern (without / delimiters)”, for example (\d{4})-(\d{2}).
- Enter flags in “Flags (default: g)”. Leave it empty for g; anything you type replaces g, so use gi for a global, case-insensitive search.
- Press Run tool. The result is a JSON list giving each match’s index (counted from 0), the matched text and its capture groups.
Good to know
- Input text is limited to 50,000 characters and the pattern to 1,000.
- Matches are capped at 1,000; the default flag is g.
- Patterns run in a worker and stop after one second.
- The result is JSON text produced in your browser.
Examples
- (\d{4})-(\d{2}) on “Due 2026-11 and 2027-01” → two matches: index 4, “2026-11”, groups ["2026","11"]; and index 16, “2027-01”, groups ["2027","01"].
- cat with the flag i on “Cat cat” → one match, “Cat” at index 0, because i on its own has no g.
- (a)|(b) on “b” → groups [null, "b"]. A group that didn’t take part in the match shows as null.
If something goes wrong
The result is [] although the text clearly matches.
Remove the slashes: /cat/ searches for the characters /cat/ literally. Matching is also case-sensitive unless you add i.
Invalid regular expression or Invalid flags.
The browser rejected the pattern or flags, for example an unclosed [ or an unknown flag such as x. JavaScript flags are d, g, i, m, s, u and y, plus v in recent browsers.
Pattern exceeded the one-second limit. Simplify it and try again.
Nested quantifiers such as (a+)+ can backtrack for a very long time. Make the pattern more specific, or test it on a shorter sample.
Limit text to 50,000 characters and pattern to 1,000.
Test a representative sample instead of the whole file.
Questions
Should I type /pattern/g?
No. Enter only the pattern and put g in the flags field.
Why did I get only one match?
Without the g flag, the worker stops after the first match.
What happens with a slow pattern?
The worker is stopped after one second and shows an error.
Are named groups shown by name?
No. Named groups still match, but the groups list shows captures by position only.
Can I test a replacement?
No. This tool lists matches only; it has no replacement field.
Next steps: Find and replace · Text difference checker · JSON validator
