Regex Tester
Type a regular expression and some test text to see every match highlighted, with its position and capture groups, as you type. Toggle the g, i, m, s, u and y flags and preview a replacement using $1 or $<name>. It uses your browser's JavaScript engine, and a runaway pattern is stopped after 1.5 seconds. Nothing is uploaded.
Updated
How to use the Regex Tester
- 1Type the pattern without the surrounding slashes.
- 2Tick the flags you need — g to find every match, i to ignore case.
- 3Paste the text to test against and read the highlighted matches and the groups table.
- 4Optionally tick Test a replacement and enter a template such as $3/$2/$1.
How it works
Matching uses the browser's own RegExp engine, so a pattern behaves exactly as it will in JavaScript and TypeScript code. Other languages' engines — PCRE in PHP, Python's re, Java — share most syntax but differ in details such as lookbehind support and named-group syntax.
Without the g flag only the first match is found, which is what JavaScript's match() and exec() return. With g, every match is listed; empty matches (from patterns like a*) are shown as a thin marker and the search moves on one character, as matchAll does.
Capture groups are numbered from 1 in the order their opening brackets appear. A group that did not take part in a match is shown as “not matched”, which is different from matching an empty string.
The replacement preview uses String.replace: $1 to $99 insert numbered groups, $<name> a named group, $& the whole match, $` and $' the text before and after, and $$ a literal dollar sign.
The pattern runs in a background worker. Nested quantifiers such as (a+)+ can take exponentially long on some inputs — catastrophic backtracking — so the worker is stopped after 1.5 seconds and the page stays usable. The first 1,000 matches are listed.
Everything runs in this page. Nothing you paste is transmitted, logged or stored, which is what makes it safe to drop a production payload in here while you are debugging.
Worked example
Reformatting ISO dates with (\d{4})-(\d{2})-(\d{2}) and the g flag
- Text: Due 2026-10-20 and 2026-11-03
- Matches: 2026-10-20 and 2026-11-03, each with groups $1 year, $2 month, $3 day
- Replacement $3/$2/$1 → Due 20/10/2026 and 03/11/2026
Result: Two matches, each split into three groups, and both dates rewritten day first.
Tips and common mistakes
- Start with a small sample text where you know which parts should match.
- Use non-capturing groups (?:…) when you only need grouping, so $1 and $2 stay predictable.
- Prefer specific classes such as [^,]+ over .* — they are faster and match less by accident.
- Anchor with ^ and $ (and the m flag for lines) when validating whole values.