Regex tester
Test a regular expression live: highlighted matches, capture groups and replacement.
Matches
Match details
Replace
$1, $<name>, $& and $$ are supported.
Runs entirely in your browser. Your files never leave your device.
About this tool
Writing a regular expression is trial and error. Type a pattern and some sample text, and every match is highlighted as you type, with its position and the content of each capture group, numbered or named. Toggle the global, case-insensitive, multiline, dot-all and Unicode flags to see how they change the result.
The replacement panel previews a search and replace on the whole text, with $1, $
How it works
- Type the pattern without the surrounding slashes.
- Choose the flags.
- Paste the text to test and read the highlighted matches and groups.
- Optionally type a replacement and copy the result.
The tool uses your browser’s JavaScript engine (ECMAScript syntax): lookbehind, named groups and Unicode property escapes are supported. Other flavours such as PCRE or Python differ on a few points.
Worked example
To turn ISO dates into day/month/year, use the pattern (\d{4})-(\d{2})-(\d{2}) with the g flag: on “Due 2026-11-29, paid 2026-12-03” both dates are highlighted with their three groups. The replacement $3/$2/$1 previews “Due 29/11/2026, paid 03/12/2026”.
Share the link with a colleague: it keeps the pattern and flags, not your test text.
Good to know
- Without the g flag, only the first match is found; that is the most common surprise.
- Anchor patterns with ^ and $ (and the m flag for multiline text) when validating whole lines.
- Nested quantifiers such as (a+)+ can freeze any regex engine on long text; simplify them.