How to use it
- Type your pattern between the slashes, or start from an example.
- Tick the flags you need (g, i, m, s, u).
- Paste your test text and watch the matches highlight.
- Optionally test a replacement with $1 or $<name>.
How the tester works
The tester runs your pattern with the JavaScript (ECMAScript) regex engine, the same one built into every browser and Node.js. As you type, it shows:
- every match highlighted in the test text,
- a table with the position (index) of each match and its capture groups, named or numbered,
- the number of matches and how long the search took,
- an optional replacement preview, so you can check
str.replace()before you put it in code.
The search runs in a separate background thread (a Web Worker) with a 2-second limit. A badly written pattern cannot freeze the page; it is stopped, and you get a hint to simplify it. Your pattern and text never leave your browser.
Flags
| Flag | Name | Effect |
|---|---|---|
g | global | Find all matches, not just the first |
i | ignore case | a matches A |
m | multiline | ^ and $ match at the start and end of every line |
s | dotAll | . also matches line breaks |
u | unicode | Full Unicode support, needed for \p{L} and emoji |
Without g, only the first match is shown, just like RegExp.exec() in JavaScript.
Cheat sheet
| Pattern | Matches |
|---|---|
\d \w \s | digit, word character (letter, digit, _), whitespace |
\D \W \S | the opposite of each |
. | any character except a line break |
[abc] [^abc] [a-z] | one of, none of, a range |
* + ? | 0 or more, 1 or more, 0 or 1 |
{3} {2,5} | exactly 3, from 2 to 5 |
*? +? | lazy versions: match as little as possible |
^ $ \b | start, end, word boundary |
(…) (?:…) | capture group, non-capturing group |
(?<name>…) | named group, used as $<name> in replacements |
a|b | a or b |
(?=…) (?!…) (?<=…) (?<!…) | lookahead and lookbehind |
\p{L} | any letter in any language (needs u) |
Example: reformat dates with named groups
The default example finds ISO dates and swaps them to the US format:
- Pattern:
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})with thegflag - Text:
The contract starts on 2026-11-02 and runs until 2027-01-31. - Replacement:
$<month>/$<day>/$<year> - Result:
The contract starts on 11/02/2026 and runs until 01/31/2027.
In replacements, $& inserts the whole match, $1, $2 the numbered groups and $<name> a named group. The built-in examples also cover email addresses, US phone numbers like (555) 123-4567, ZIP and ZIP+4 codes, and Unicode words.
Avoiding catastrophic backtracking
Some patterns take exponential time on certain inputs. The classic case is a nested quantifier such as (a+)+$ run against aaaaaaaaaaaaaaaaaaaaaaaa!: the engine tries every way of splitting the a's between the inner and outer + before giving up. In production, this is a real denial-of-service risk (ReDoS).
To stay safe:
- avoid quantifiers inside quantified groups, like
(\w+)*, - make alternatives mutually exclusive, so
(a|a)*cannot match the same text two ways, - prefer specific classes like
[^"]*over.*.
If the tester stops your search after 2 seconds, that is the warning sign.
Testing patterns before you ship them
A few habits save a lot of debugging:
- Test the failures too. Paste text that should not match, such as an email address without a domain or a ZIP code with four digits, and make sure nothing is highlighted.
- Anchor validation patterns. For checking a whole input, wrap the pattern in
^…$. Without anchors,\d{5}happily matches the first five digits of123456789. - Escape special characters. To match a literal dot, plus or parenthesis, write
\.,\+or\(. - Remember string escaping. In JavaScript source code, a pattern written as a string needs doubled backslashes:
new RegExp("\\d+"). A regex literal/\d+/does not. - Keep it readable. If a pattern grows beyond one line, split the job into two simpler patterns or add a comment in your code explaining each part.
Frequently asked questions
Which regex flavor does this tester use?
JavaScript (ECMAScript), as in browsers and Node.js. PHP (PCRE), Python and Java are similar but differ in some features, such as possessive quantifiers and inline flags.
How do I see capture groups?
Matches are listed in a table under the highlighted text, with each numbered or named group and its value.
How do I test a replacement?
Tick Test a replacement and type the replacement string. Use $1, $<name> or $& to insert groups or the whole match.
Why did my regex time out?
The pattern probably backtracks too much, often because of nested quantifiers like (a+)+. Simplify it or make it more specific.
Is my text uploaded?
No. Matching runs in a background thread in your own browser.
Last updated: November 12, 2026