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), s (let
.match newlines), u (Unicode — an emoji counts as one character), and y (sticky).
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