Knowledge Mark G
Hire Me

Free developer tool

Regex Tester

Test regular expressions live, with every match highlighted, capture groups listed and a replace preview.

  • No sign-up
  • Instant results
  • Runs in your browser

Pattern

//gi
Test string
Replace

Matches

Type a pattern to start matching.

Cheat sheet

.
any character except newline
\d \w \s
digit, word character, whitespace
\D \W \S
the opposite of each
[abc] [^abc]
one of / none of these
a* a+ a?
0 or more, 1 or more, 0 or 1
a{3} a{2,5}
exactly 3, between 2 and 5
a*? a+?
lazy - as few as possible
^ $
start / end of string (or line with m)
\b
word boundary
(…) (?:…)
capture group / group without capturing
(?<name>…)
named group - $<name> in a replacement
a|b
a or b
(?=…) (?!…)
followed by / not followed by
(?<=…) (?<!…)
preceded by / not preceded by

A regex tester that cannot freeze your tab

Matching runs in a background worker. A pattern with nested quantifiers - (a+)+ is the classic one - can take exponential time on the wrong input, and in most online testers that locks up the page. Here the worker is stopped after 1.5 seconds and you are told why, which is also a useful warning before that pattern reaches production.

Flags

g finds every match rather than the first; i ignores case; m makes ^ and $ match at line breaks; s lets the dot match newlines; u turns on full Unicode, including \p{L} classes; y anchors each match to where the last one ended.

JavaScript, Python, C# and others

The tester uses your browser’s JavaScript engine. The everyday syntax - classes, quantifiers, groups, anchors, lookahead - behaves the same in Python, Java, C#, PHP and Go. The differences are at the edges: lookbehind support, named-group syntax ((?P<name>…) in Python), and possessive quantifiers. Test those in the target language too.

Replacements

Turn on the replace preview to see the result of a substitution. Use $1, $2 for numbered groups, $<name> for named groups and $& for the whole match. Cleaning up data before an import? The CSV to JSON converter and JSON formatter sit alongside it.

Questions people ask

Which regex flavour does this use?+

JavaScript (ECMAScript), running in your browser. Most syntax is shared with Python, Java, C# and PHP, but test lookbehind and named groups in your target language.

Why did my pattern stop with a timeout?+

It backtracked catastrophically - usually a quantified group containing another quantifier, like (\w+)*. Make the inner part more specific, or anchor the pattern, so the engine has fewer ways to try.

How do I match a literal dot or bracket?+

Escape it with a backslash: \. matches a dot, \( a bracket, \\ a backslash. Inside a character class most symbols are literal already.

What is the difference between greedy and lazy?+

Greedy quantifiers (*, +) match as much as possible; adding ? (*?, +?) makes them match as little as possible. <.+> matches a whole line of tags; <.+?> matches one tag.

Is my test text sent anywhere?+

No. Matching happens entirely in your browser.