Regex Tester
Enter a pattern and flags, and the matches in your test string light up as you type. Check the match count, capture groups, and a replacement preview. Everything stays in your browser.
Paste a slash-style regex like /\d+/gi into the pattern box and the flags are picked up automatically.
How to Use the Regex Tester
New to regex? Start by clicking an example button (Email address, URL, Date and so on). The pattern and a matching sample text load instantly, so you can see exactly where it lands. Once you are comfortable, type your own pattern into the Regular Expression field, tick the flags you need (g / i / m / s), and paste the text you want to test into the Test String box. Matches are highlighted as you type, and the match count and capture groups are listed below.
Copy a slash-style regex such as /\d{4}-\d{2}-\d{2}/g from your code and paste it into the pattern box — the flags are read automatically. Handy for a quick check before you use it in an editor or program.
- Highlight: The parts of your test string that match the pattern are shown in color, so you can see at a glance where it lands.
- Matches: Shows how many matches were found, plus each match's full text and capture groups (
$1,$2…). - Replace Preview: Enter a string in the Replacement field to preview the result of
str.replace(). Back-references such as$1work exactly as they do in standard JavaScript. - Flags: Toggle g (all matches), i (ignore case), m (multiline), and s (let
.match newlines).
Handy For
- Checking patterns that extract dates, IPs or email addresses from logs and text
- Trial runs before you wire a pattern into form validation
- Confirming a replacement (with
$1references) before using it in an editor or on the command line - Verifying that capture groups pull out exactly the parts you intended
Frequently Asked Questions
Is my pattern or text sent to a server?
What do the g / i / m / s flags do?
^ and $ match the start and end of each line (multiline), and s lets . match newline characters too (dotAll). Toggling a checkbox updates the result on the spot.How do capture groups and the replace preview work?
( ) become capture groups and are listed per match as $1, $2 and so on. Enter a string in the Replacement field to preview the result of str.replace(), where back-references like $1 work as in standard JavaScript. The g flag controls whether one or all matches are replaced.