Skip to content
Browse tools

Regex → tester

Type a pattern and every match lights up as you type — with each capture group listed, the replacement previewed, the pattern explained token by token, and the code ready to paste into JavaScript, Python, C# or Java.

Engine
JavaScript (ECMAScript)
Shows
matches · groups · replace
Safe
runaway patterns are stopped
Step 1

Pattern & text

empty
Flags
Step 2

Matches

View
empty
Type a pattern and paste some text to see matches.
Nothing to test yet Type a pattern and paste some text.

Your pattern, explained

Type a pattern and each part of it is described here.

Regex cheat sheet

CharactersMatches
.Any character except a newline (add s to include newlines)
\d \w \sDigit · word character (letter, digit, _) · whitespace
\D \W \SThe opposite of each
[abc] [^abc]One of a, b or c · anything except them
[a-z0-9]A range of characters
\p{L}Any letter in any script (needs u)
Quantity & positionMeaning
* + ?0 or more · 1 or more · 0 or 1
{3} {2,5} {2,}Exactly 3 · 2 to 5 · 2 or more
*? +?Lazy: as few as possible
^ $Start · end of text (of each line with m)
\bWord boundary
a|ba or b
GroupsMeaning
(abc)Capture group — $1 in a replacement
(?<name>abc)Named group — $<name>
(?:abc)Group without capturing
(?=abc) (?!abc)Followed by · not followed by
(?<=abc) (?<!abc)Preceded by · not preceded by
\1 \k<name>The same text a group matched earlier

Worth knowing

This is the JavaScript engine

Patterns run on your browser's own regex engine, so what matches here is exactly what matches in JavaScript and TypeScript. Python, C# and Java agree on almost everything shown on this page; the Code view adjusts the escaping for each.

Without g, only the first match counts

That is how exec and replace behave without the global flag, so the tester behaves the same way. Turn g off when you want to see what a single match() call would return.

Runaway patterns are stopped

Nested quantifiers like (a+)+$ can take exponential time on the wrong input. Matching runs in a background worker with a time limit, so a pattern like that is reported instead of freezing the page.

Nothing is uploaded

Your pattern and text stay in this tab. A share link carries them in the part of the URL after #, which browsers never send to a server.