About this tool
Regular expressions (regex) are search patterns used to search, validate and transform text – for example to validate e-mail addresses, extract data from log files or replace many occurrences at once in an editor.
With this tester you try out JavaScript regex live: matches are highlighted in the text, groups and named groups are listed individually, and a replace preview shows the result of replace(). A cheat sheet explains the most important building blocks. Expressions that run for too long are stopped automatically so your browser does not freeze.
How it works
- Enter the regular expression without surrounding slashes.
- Choose the flags, e.g. g for all matches or i to ignore case.
- Paste your test text – all matches are highlighted instantly and listed below with position and groups.
- Optionally enter a replacement, e.g. $1 for the first group, and check the result.
Frequently asked questions
Which regex flavor is used?
Your browser’s JavaScript engine (ECMAScript). It supports lookbehind, named groups and Unicode properties. Some features of other flavors like PCRE (e.g. possessive quantifiers or recursive patterns) are not available.
Why does my expression only find the first match?
Without the g (global) flag the search stops after the first match. Enable g to find and replace all occurrences.
How do I reference groups in the replacement?
$1, $2 etc. insert the content of that group, $<name> a named group and $& the whole match. Write $$ for a literal dollar sign.
What is “catastrophic backtracking”?
Some patterns with nested repetition, e.g. (a+)+, need exponentially many steps for certain inputs. The tool stops such expressions. Avoid nested quantifiers or make the pattern more specific.
How do I count how often a word occurs?
With the g flag the tester shows the total number of matches. For general text statistics and the most frequent words, use the Word & Character Counter.