Regex Tester
Test regular expressions against sample text with live match highlighting.
This tool needs JavaScript enabled to run in your browser.
What this tool does
The Regex Tester runs a regular expression against your sample text and highlights every match, with each capture group broken out so you can see exactly what the pattern caught. It uses the same regular expression engine your browser and Node.js use, so what works here works in your JavaScript code.
How to use it
- Type your pattern between the slashes.
- Set the flags you need:
gglobal,icase-insensitive,mmultiline,sdotall,uunicode. - Paste the text to test against.
- Read the highlighted matches and the group details below.
A note on slow patterns
Some patterns backtrack catastrophically on certain input and can take a very long time to finish. To keep the page responsive, matching runs in a background worker with a time limit. If a pattern exceeds it, the tool stops and tells you, rather than freezing. If that happens, look for nested quantifiers such as (a+)+ and rewrite them.
Common use cases
- Building a pattern to extract values from log lines or free text.
- Checking that a validation regex accepts the inputs you expect and rejects the ones you do not.
- Working out why a pattern matches more, or less, than you intended.
Regular expression dialects differ. This tester is the JavaScript flavour; features such as lookbehind depend on the browser, and other languages differ on named groups and Unicode handling.
Frequently asked questions
- Which regex flavour is this?
- It uses the JavaScript (ECMAScript) regular expression engine built into your browser, including flags such as g, i, m, s and u.
- Can a bad pattern hang my browser?
- Matching runs with a guard that stops runaway patterns (catastrophic backtracking) rather than freezing the page, and reports when it had to stop.
Learning resources
Testsmith also runs hands-on courses and a free practice app for the skills behind this tool.