Regex Tester
Type a regular expression and some test text to see every match highlighted as you type — with capture groups, named groups, positions and a live replace preview. It uses your browser's own JavaScript regex engine, so what matches here matches in your code.
Every match, with its position and groups, will be listed here.
How This Regex Tester Works
Your browser's own JavaScript engine — so results match your code.
Type a pattern without the surrounding slashes, pick flags with the buttons, and type or paste your test text. Every match is highlighted as you type. Switch to Matches to see each match with its position, numbered groups and named groups, or to Replace to preview text.replace(regex, replacement).
You can also paste a whole JavaScript literal such as /^\d{3}-\d{4}$/gm into the pattern box — it's split into the pattern and its flags automatically. Copy as /regex/ does the reverse, escaping any / in the pattern for you.
Safe with any pattern. Some patterns, like (a+)+$, take exponentially long on certain text — this is called catastrophic backtracking, and it can freeze a page or a server. Here each test runs in a background worker. If it takes more than about 2 seconds it is stopped and you get a warning, and your browser stays responsive.
JavaScript only. Regex flavours differ: Python, PHP (PCRE), Java and .NET support features JavaScript doesn't, such as possessive quantifiers or inline (?x) comments, and vice versa. Test those patterns in their own language. Your test text is never stored or sent anywhere.
JavaScript Regex Cheat Sheet
The most-used syntax. All of it works in this tester.
| Syntax | Meaning |
|---|---|
. | Any character except line breaks (any character at all with the s flag) |
\d \w \s | Digit 0–9 · word character A–Z a–z 0–9 _ · whitespace. Uppercase (\D \W \S) means “not”. |
[abc] [^abc] [a-z] | One of a, b, c · anything except a, b, c · a range |
^ $ | Start · end of the text (of each line with the m flag) |
\b \B | Word boundary · not a word boundary |
* + ? | 0 or more · 1 or more · 0 or 1. Add ? to make them lazy: *? +? ?? |
{3} {2,} {2,5} | Exactly 3 · 2 or more · 2 to 5 |
(…) (?:…) | Capturing group · non-capturing group |
(?<name>…) \k<name> | Named group · back-reference to it (\1 for numbered groups) |
a|b | a or b |
(?=…) (?!…) | Lookahead · negative lookahead |
(?<=…) (?<!…) | Lookbehind · negative lookbehind |
\p{L} \p{Emoji} | Unicode property, e.g. any letter (needs the u or v flag) |
$1 $<name> $& $$ | In the replacement: group 1 · a named group · the whole match · a literal $. Also $` (text before) and $' (text after). |
How to Use the Regex Tester
Get your result in under ten seconds.
Type a pattern
Without slashes — or paste a whole /pattern/flags literal.
Add test text
Matches are highlighted as you type.
Inspect or replace
See groups and positions, or preview a replacement.
Why Use the Regex Tester on Developers Web Tools
Fast, accurate and private — built for developers.
Live results
Highlighting updates as you type, even on long text.
Groups
Numbered and named groups for every match, with positions.
Replace preview
See the result of replace() with $1, $<name> and $&.
Runaway-safe
Catastrophic backtracking is stopped after about 2 seconds.
All flags
g, i, m, s, u, v, y and d — the full JavaScript set.
Private
Your text stays in your browser and is never stored.
Frequently Asked Questions
JavaScript (ECMAScript), using the RegExp engine built into your browser — the same one Node.js, Deno and Chrome-based browsers use. Most everyday syntax is shared with Python, PHP, Java and .NET, but some features differ, so test patterns for those languages in their own environment.
Turn on the g (global) flag. Without it, JavaScript stops after the first match — that's how exec(), match() and replace() behave in your code too.
Patterns with nested repetition, such as (a+)+$ or (\w+\s?)+$, can try an exponential number of ways to match when the text almost-but-doesn't match. A few dozen characters can take minutes. This tester stops a run after about 2 seconds and warns you. Fix it by removing the nested quantifier or making the alternatives unambiguous.
Use $1, $2… for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign. With the g flag every match is replaced; without it only the first.
Both turn on full Unicode mode (\u{1F600}, \p{…}, emoji counted as one character). v is newer and adds set operations inside brackets, like [\p{L}--[a-z]], and stricter escaping rules. You can't use both at once. If your browser is too old for v, its button is disabled.
They are JavaScript string indexes (UTF-16 code units) — exactly what match.index returns in your code. Emoji and some rare characters count as 2.
No. Everything runs in your browser. The text, pattern and results are never sent anywhere or saved, and they're gone when you close the page.