Regex Tester Live

Match highlighting, capture groups, example strings it accepts and rejects, a replace preview and a cheat sheet — with runaway-pattern protection.

In-browser & private
Advertisement
Test string Matches update as you type
Result
Enter a pattern and some test text, or press Load sample.
Matches 0 Groups 0 Time Length 0 Ready

Cheat sheet

. any character
\d digit   \D non-digit
\w word char   \W non-word
\s whitespace   \S non-space
[abc] any of a, b, c
[^abc] none of them
[a-z] range
\b word boundary
* 0+   + 1+   ? 0 or 1
{2,5} 2 to 5 times
+? lazy (shortest match)
(…) capture group
(?:…) non-capturing
(?<n>…) named group
a|b either
^ start   $ end
\1 backreference to group 1
(?=…) lookahead   (?!…) negative
(?<=…) lookbehind   (?<!…) negative

About this tester

This uses the JavaScript (ECMAScript) regex engine, the same one your browser and Node.js use. Java's java.util.regex is very close, but differs on a few things — Java needs double backslashes in string literals ("\\d"), and supports possessive quantifiers (a++) which JavaScript does not.

Patterns run inside a Web Worker with a time limit, so a catastrophic pattern like (a+)+$ is stopped instead of freezing the page.

The Examples are built from the pattern and then checked by the engine against the whole string, so every accept and reject shown is real. Paste a Java string such as "^\\d+$" and the quotes and doubled backslashes are removed for you.

More free tools