Regex Tester
Test a regular expression and inspect its matches and groups
Expression
/
/g
The expression took more than a second and was stopped. It probably backtracks catastrophically, as nested quantifiers like
(a+)+ do.
Matches
| # | Position | Match | Groups |
|---|
Replace
$1, $2… insert a group, $<name> a named group, $& the whole match, $$ a dollar sign.
Cheat sheet
.- Any character except a line break (any at all with the s flag)
\d \w \s- Digit, word character [A-Za-z0-9_], whitespace; \D \W \S negate them
[abc] [^abc] [a-z]- One of, none of, a range
^ $ \b- Start, end (of a line with the m flag), word boundary
* + ? {2,5}- 0 or more, 1 or more, optional, between 2 and 5; add ? to match as few as possible
(…) (?<name>…) (?:…)- Capturing group, named group, non-capturing group
a|b- a or b
(?=…) (?!…) (?<=…) (?<!…)- Followed by, not followed by, preceded by, not preceded by
\1 \k<name>- The text matched by group 1, by a named group
\p{L}- A Unicode letter, with the u flag (also \p{N}, \p{Emoji}…)