Regex Tester

Test JavaScript regular expressions live with match highlighting and capture groups.

Flags

Type a pattern and some text; results update as you type.

Matches highlighted

What this tool does

Test a JavaScript regular expression against real text and see every match instantly. Type the pattern without surrounding slashes, tick the flags you need, and paste your sample text: matches are highlighted in place, listed in a table with their position and capture groups (numbered and named), and counted in the status line. Add a replacement string to preview what String.prototype.replace would return, including $1, $& and $<name> references. Invalid patterns show the browser's own error message so you can fix them before pasting the expression into your code. Because the engine is the same one your browser runs, what works here works in Node.js, Deno and front-end code.

Regex cheat sheet

.Any character except a line break (any character with the s flag)
\d \w \sDigit; word character (letters, digits, _); whitespace
\D \W \SThe opposite of \d, \w and \s
[abc] [a-z] [^abc]One character from the set, a range, or anything not in the set
^ $Start and end of the text (of each line with the m flag)
\b \BWord boundary; not a word boundary
a* a+ a?Zero or more; one or more; zero or one
a{3} a{2,5} a{2,}Exactly 3; between 2 and 5; at least 2
a*? a+? a??Lazy versions: match as little as possible
a|bEither a or b
(…) (?:…)Capture group; non-capturing group
(?<name>…)Named capture group, read with $<name> in replacements
\1 $1 $<name>Back-reference in the pattern; group reference in the replacement
(?=…) (?!…)Positive and negative lookahead
(?<=…) (?<!…)Positive and negative lookbehind
\. \\ \/Escape a special character to match it literally
\u{1F600} \p{L}Code point and Unicode property escapes (need the u flag)

Notes

Privacy

Patterns and test text are processed in your browser only; nothing is uploaded or stored.