Regex Tester
Write a regular expression and watch it match your text as you type.
| # | Index | Match | Groups |
|---|---|---|---|
| No matches yet. | |||
Regex cheat sheet
| . | Any character except a line break |
| \d \w \s | Digit, word character, whitespace |
| \D \W \S | The opposite of the above |
| [abc] [^abc] | One of a, b or c / anything but them |
| [a-z0-9] | A character in a range |
| ^ $ | Start / end of input (or line with m) |
| \b | Word boundary |
| * + ? | 0 or more, 1 or more, 0 or 1 |
| {3} {2,5} {2,} | Exactly 3, 2 to 5, 2 or more |
| *? +? | Lazy: match as little as possible |
| (…) | Capture group, referenced as $1 |
| (?<name>…) | Named group, referenced as $<name> |
| (?:…) | Group without capturing |
| a|b | a or b |
| (?=…) (?!…) | Followed by / not followed by |
| (?<=…) (?<!…) | Preceded by / not preceded by |
| \p{L} | Any letter in any language (needs u) |
| \. \* \( | Escape a special character |
How to use the Regex Tester
- Type your pattern in the top field and switch flags such as g (all matches) or i (ignore case) on or off.
- Paste the text you want to search into the test area. Matches are highlighted as you type.
- Check the match list for each match's position, its numbered groups and its named groups.
- Enter a replacement such as $1 or $<name> to preview a find-and-replace, then copy the result.
About this tool
Regular expressions are compact patterns for finding text: email addresses in a log, dates in a document, or every line that starts with a warning. They are powerful but easy to get subtly wrong. This tester shows the effect of every keystroke immediately by highlighting each match in your sample text and listing it with its position and capture groups.
It uses the JavaScript regex engine built into your browser, so results match exactly what your code will do in Node.js, Deno or the browser. All six common flags are available: global, ignore case, multiline, dotAll, unicode and sticky. When a pattern is invalid, you get a plain explanation such as "a ( is never closed" instead of a cryptic engine message. The replace preview supports $1, $& and named references like $<year>.
Some patterns, like (a+)+$, can take exponentially long on certain inputs. Matching runs in a background worker with a time limit, so a runaway pattern is stopped with a warning instead of freezing the page. Tip: paste a literal like /\d+/gi into the pattern box and the flags are picked up automatically.
Frequently asked questions
Is my test text uploaded?
No. Matching happens in your browser using its own regex engine. Your pattern and text stay on your device and are only remembered in local storage for convenience.
Which regex flavour does this use?
JavaScript (ECMAScript). Most syntax is shared with PCRE, Python and Java, but some features differ. For example, possessive quantifiers and inline (?i) modifiers are not supported in most browsers.
Why does only one match appear?
Without the g (global) flag, JavaScript stops after the first match. Turn on g to find every match.
What does the "took too long" warning mean?
The pattern triggers catastrophic backtracking: nested repetition like (a+)+ makes the engine try a huge number of combinations. Make the repetition more specific or remove the nesting.
How do I use a capture group in the replacement?
Use $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign.