Developer tool

Regex tester

Write a regular expression and see what it matches as you type. Uses JavaScript's regex engine, the same one as your browser and Node.js.

Advertisement
//

Matches highlighted

Matches

Replace

Use $1, $2 for groups, $<name> for named groups, and $& for the whole match.

Advertisement

Regex cheat sheet

PatternMatches
.Any character except a new line
\d \w \sA digit, a word character (letter, digit, _), a space or tab
\D \W \SThe opposite of the above
[abc] [^abc] [a-z]One of a, b or c · anything except them · a to z
* + ? {3} {2,5}0 or more · 1 or more · optional · exactly 3 · 2 to 5 times
*? +?As few as possible (lazy)
^ $ \bStart · end · a word boundary
(abc) (?:abc) (?<name>abc)Capture group · group without capturing · named group
a|ba or b
(?=x) (?!x) (?<=x) (?<!x)Followed by x · not followed by x · after x · not after x
\. \* \( \\A real dot, star, bracket or backslash

Useful patterns

The page froze on my pattern.

Some patterns, like (a+)+$, can take an extremely long time on certain text ("catastrophic backtracking"). Reload the page and rewrite the pattern without nested repeats.

Advertisement