Regex tester
Test a regular expression against sample text with live match highlighting, capture groups, flag toggles and a replace preview. A cheatsheet is built in. Fully offline.
Open Regex tester →What is the regex tester?
A tool for testing a regular expression against sample text with live match highlighting, a count of matches, flag toggles and a replace preview — plus a quick cheatsheet. It runs entirely in your browser, with no internet needed, and remembers your pattern and text on this device.
How to use Regex tester
- Type your pattern — Enter a regular expression between the slashes. Toggle the flags — g, i, m, s and u — to control global, case-insensitive, multiline, dotall and unicode matching.
- Paste test text — Add your sample text in the Test string box. Matches are highlighted live as you type, with a running count.
- Check the matches — Review the highlighted matches to confirm your pattern catches exactly what you intend, and nothing extra.
- Preview a replacement — Type a replacement in the Replace box — use $1, $2 to reference capture groups — to preview the substituted result.
Frequently asked questions
Which regex flavour does it use?
It uses the browser's built-in JavaScript regular-expression engine, so patterns behave exactly as they would in JavaScript code.
What do the flag buttons do?
g matches all occurrences, i ignores case, m makes ^ and $ match line breaks, s lets the dot match newlines, and u enables full unicode matching.
How do I use capture groups in a replacement?
Reference each captured group in the Replace box with $1, $2 and so on — the preview shows the substituted output live.
Is my pattern and text saved?
Yes. Your pattern and test string are stored in your browser on this device, so they're still there when you return. Nothing is uploaded.
What if my pattern is invalid?
If the expression can't be compiled, an error message appears so you can fix the syntax before testing.
Tips
- Turn on the g flag to see every match rather than just the first.
- Use the built-in cheatsheet for quick reminders of tokens like \d, \b and {2,4}.
- Test edge cases — empty lines, trailing spaces — by pasting them into the test box.
- Build groups with (…) so you can reuse them as $1, $2 in the replace preview.