Regex Tester
Build a JavaScript regular expression and see matches, capture groups, and a live replace preview as you type. Toggle the g i m s u y flags, and invalid patterns show a friendly error instead of breaking.
10241024222288176176Regex cheat sheet
The most common tokens for building a pattern. Character classes match a single character, while quantifiers like *, +, and ? control how many times the token before them repeats.
| Token | Matches |
|---|---|
\d | Any digit, 0 to 9 |
\w | A word character: letter, digit, or underscore |
\s | Any whitespace (space, tab, newline) |
. | Any character except a line break |
^ | Start of the string (or line with the m flag) |
$ | End of the string (or line with the m flag) |
* | Zero or more of the preceding token |
+ | One or more of the preceding token |
? | Zero or one — makes the token optional |
{n,m} | Between n and m repetitions |
[...] | Any one character in the set |
(...) | A capturing group |
| | Alternation — match the left or right side |
\b | A word boundary |
Regex testing, explained
What do the flags g, i, m, s, u, and y mean?+
g finds all matches instead of just the first, i ignores case, m makes ^ and $ match at line breaks, s lets the dot match newlines, u enables full unicode mode, and y (sticky) only matches starting exactly at the last index.
Why does my pattern show an error?+
The tool builds your pattern with new RegExp inside a try/catch. If the syntax is invalid, for example an unclosed group like "(", it shows the browser error message instead of crashing. Fix the pattern and the results update instantly.
What are capture groups?+
Parentheses in a pattern capture part of each match. The tool lists every group per match, numbered from 1, plus any named groups written as (?<name>...). Groups that did not participate in the match are shown as no match.
How does the Replace field work?+
It runs testString.replace(regex, replacement) live. You can use standard replacement tokens: $1, $2 for capture groups, $& for the whole match, $<name> for named groups, and $$ for a literal dollar sign.
Does my text leave my browser?+
No. This regex tester is completely free with no login, and your pattern and test string are evaluated entirely in your browser. Nothing is uploaded to a server.
Related tools
All tools →More in General Tools.

