Regex Tester
This regex tester shows every match, capture group and replacement as you type.
Use $1 for a group, $<name> for a named group and $& for the whole match.
2 matches
Contact ada@example.com for billing, or Grace.Hopper+news@navy.mil for the newsletter. Not an address: hello@ or @example.com
| # | Index | Match | Group 1 | Group 2 | <user> | <domain> |
|---|---|---|---|---|---|---|
| 1 | 8 | ada@example.com | ada | example.com | ada | example.com |
| 2 | 40 | Grace.Hopper+news@navy.mil | Grace.Hopper+news | navy.mil | Grace.Hopper+news | navy.mil |
Replace preview
Contact ada at example.com for billing, or Grace.Hopper+news at navy.mil for the newsletter. Not an address: hello@ or @example.com
How to test a regular expression
- Type the pattern without the surrounding slashes and switch flags on or off with the buttons —
gto find every match. - Paste your test text. Matches are highlighted as you type, and the table lists each match with its position and capture groups.
- Tick Replace with to preview a replacement using
$1or$<name>.
This tester uses the JavaScript regular-expression engine of your browser, so results match RegExp in JavaScript and Node.js exactly. Other languages share most syntax, but not all of it.
Regex examples
Pattern: (?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2}) flags: g
Replace with: $<d>.$<m>.$<y>
2026-10-14 → 14.10.2026Pattern: [ \t]+$ flags: gm
Replace with: (empty)const re = /(?<user>[\w.+-]+)@(?<domain>[\w-]+\.[\w.]+)/gi;
for (const m of text.matchAll(re)) {
console.log(m.index, m.groups.user, m.groups.domain);
}Regex cheat sheet
| Syntax | Meaning |
|---|---|
| . | any character except a line break (with s: any character) |
| \d \w \s | digit, word character, whitespace |
| \D \W \S | the opposite of each |
| [abc] [^abc] [a-z] | one of, none of, a range |
| ^ $ | start and end of the text (with m: of each line) |
| \b | word boundary |
| * + ? | 0 or more, 1 or more, 0 or 1 |
| {3} {2,5} {2,} | exactly 3, between 2 and 5, at least 2 |
| *? +? | lazy: as few as possible |
| (…) (?:…) | capture group, non-capturing group |
| (?<name>…) | named group, used as $<name> |
| a|b | a or b |
| (?=…) (?!…) | lookahead, negative lookahead |
| (?<=…) (?<!…) | lookbehind, negative lookbehind |
Catastrophic backtracking
Some patterns take exponentially longer as the input grows — for example ^(a+)+$ against a long run of a followed by a b. In a real application that can freeze a server (a so-called ReDoS). Here each test runs in a separate background thread and is stopped after 1.5 seconds, so you can find such patterns safely. The fix is usually to make the repeated parts unable to match the same text in different ways.
Related developer tools
Compare text before and after a replacement with the diff checker, decode URLs before matching them with the URL decoder, or tidy the script that uses your pattern with the JavaScript formatter.
Frequently asked questions
- Which regex flavor does this tester use?
- Your browser’s JavaScript engine, exactly as RegExp works in JavaScript and Node.js. Most syntax is shared with PCRE, Python and Java, but some features differ: JavaScript has no possessive quantifiers or atomic groups, and lookbehind support depends on the engine. Test in the target language before relying on advanced features.
- What do the flags mean?
- g finds all matches, i ignores case, m makes ^ and $ match at line breaks, s lets . match line breaks, u enables full Unicode, v is the newer Unicode-sets mode, y matches only at the current position, and d records the positions of groups.
- How do I use groups in the replacement?
- Write $1, $2… for numbered groups, $<name> for named groups such as (?<year>\d{4}), $& for the whole match and $$ for a literal dollar sign. The replace preview updates as you type.
- Why was my pattern stopped?
- Patterns with nested quantifiers like (a+)+ can take exponential time on some inputs — called catastrophic backtracking. Each test runs in a separate thread, and if it takes longer than 1.5 seconds it is stopped so the page doesn’t freeze. Rewrite the pattern so that quantified parts can’t overlap.
- Is my test data sent to a server?
- No. Patterns and test strings are evaluated in your browser only.