Regex tester
Write a pattern, paste some text, and see every match and group highlighted as you type.
After replacing
| # | Match | At | Groups |
|---|
Cheat sheet
| Syntax | Means |
|---|---|
. | Any character except a line break |
\d \w \s | A digit, a word character, whitespace |
\D \W \S | Anything except those |
[abc] [^abc] | One of a, b or c; anything but them |
[a-z] | A character in the range |
^ $ | Start and end of the input (or line, with m) |
\b | A word boundary |
* + ? | Zero or more, one or more, zero or one |
{3} {2,5} | Exactly 3; between 2 and 5 |
*? +? | As few as possible (lazy) |
(abc) | Capture a group |
(?<name>abc) | Capture a named group |
(?:abc) | Group without capturing |
a|b | a or b |
(?=abc) (?!abc) | Followed by; not followed by |
(?<=abc) (?<!abc) | Preceded by; not preceded by |
\1 \k<name> | Repeat what a group matched |
Questions people ask
Which regex flavor does this use?
JavaScript (ECMAScript), exactly as your browser runs it. Most syntax is shared with Python, Java and PCRE, but details like lookbehind and named-group syntax can differ.
Why does my pattern time out?
Some patterns, like (a+)+$, can take exponential time on inputs that almost match. This tester runs your pattern in a background worker and stops it after one second.
How do I use groups in the replacement?
Use $1, $2 for numbered groups, $<name> for named groups, and $& for the whole match.