Test regular expressions with live results
Regular expressions are powerful but famously hard to read. This regex tester shows you exactly what your pattern does while you type: every match is highlighted in the text, counted, and listed with its position and capture groups. A replace preview shows the result of a search-and-replace before you run it in your code. Everything runs locally in your browser, inside a background worker that protects the page from runaway patterns.
Features
- Live highlighting of all matches in the test string.
- Flag toggles for
g,i,m,sandu, with the full/pattern/flagsliteral shown. - Match table with index, numbered capture groups and named groups.
- Replace preview supporting
$1,$<name>,$&and other replacement patterns. - Clear error messages for invalid syntax, and a one-second safety timeout for catastrophic backtracking.
Practical uses
Validating input. Build and test patterns for postcodes, product codes or usernames against a list of valid and invalid samples before adding them to a form.
Extracting data. Pull email addresses, URLs, dates or IDs out of logs and documents. Capture groups let you split each match into parts, such as user and domain.
Search and replace. Reformat dates from MM/DD/YYYY to YYYY-MM-DD, rename variables, or clean up exported data. Preview the replacement here, then use the same pattern in your editor or script.
Learning regex. Experiment with quantifiers, character classes and anchors and see the effect instantly.
Quick reference
| Syntax | Meaning |
|---|---|
. |
Any character except a line break (any character with s) |
\d \w \s |
Digit, word character, whitespace |
[abc] [^abc] |
One of / none of the listed characters |
* + ? |
0 or more, 1 or more, 0 or 1 |
{2,5} |
Between 2 and 5 times |
^ $ |
Start and end of text (of each line with m) |
(…) (?<name>…) |
Capture group, named group |
(?:…) |
Group without capturing |
(?=…) (?!…) |
Lookahead, negative lookahead |
\b |
Word boundary |
Quantifiers are greedy by default; add ? (as in .*?) to make them lazy. To clean up lists afterwards, try Remove Duplicate Lines, or compare before and after with the Diff Checker.