How to use the Regex Tester
- Type your pattern (without slashes).
- Tick the flags you need.
- Paste test text and see matches highlighted.
- Check each match's groups on the right.
What does this tool do?
The tester uses JavaScript's regular expression engine, so results match what you'll get in browsers and Node.js. It shows every match with its position, numbered groups and named groups.
Patterns run in a separate background worker with a time limit. If a pattern triggers catastrophic backtracking, it's stopped instead of freezing your browser.
Why use it?
- Build and debug patterns quickly.
- See groups for search-and-replace.
- Safe against runaway patterns.
Use cases
- Check a validation pattern (email, postcode, order number) against real examples before shipping it.
- Work out capture groups for a search-and-replace in your editor or code.
- Debug why a pattern matches too much or too little.
Example
Pattern (\w+)@(\w+)\.com with flags gi on “ada@example.com” matches the whole address, with “ada” as group 1 and “example” as group 2.
Common mistakes
- Forgetting the g flag and wondering why only the first match is found.
- Using . to mean a literal dot — escape it as \. (for example \.com).
- Greedy quantifiers: <.+> matches from the first < to the last > on the line; <.+?> stops at the first >.
Accuracy and limits
- Other languages' regex engines (PCRE, Python, Java) are similar but not identical — for example in lookbehind and Unicode support.
Privacy
Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.
Frequently asked questions
Can I test Python, Java or C# regex here?
The engine is JavaScript's, so most everyday patterns behave the same in Python, Java, C# and PCRE. Differences show up in features such as possessive quantifiers, atomic groups, inline flags like (?i) and some Unicode classes — check those in your target language.
Do I type the slashes?
No. Type only the pattern and tick the flags; the tester shows the full /pattern/flags form for you.
Why did my pattern stop with a timeout?
Some patterns, like (a+)+$, take exponential time on certain inputs (catastrophic backtracking). The tester runs patterns in a background worker with a time limit so your browser doesn't freeze, and stops them.
What do the g, i and m flags do?
g finds all matches instead of stopping at the first, i ignores upper and lower case, and m makes ^ and $ match at the start and end of every line rather than the whole text.
Last reviewed by the M2Toolkit team.