Test and Debug Regular Expressions
Type a pattern and some sample text, and every match is highlighted as you go, with capture groups listed underneath. The pattern box turns green when the expression compiles and red when it does not, so a typo shows up immediately rather than as a confusing lack of matches.
Matching uses your browser's own JavaScript regex engine, which means results here are
exactly what String.match or RegExp.exec will produce in your
code. Nothing is sent to a server.
What do the flags do?
| Flag | Name | Effect |
|---|---|---|
g | global | Find every match, not just the first |
i | ignore case | Treat A and a as the same letter |
m | multiline | ^ and $ match at each line, not just the whole string |
s | dotall | . also matches a newline |
u | unicode | Enables \p{...} classes and correct handling of emoji and other astral characters |
y | sticky | Match only at the exact current position |
Why am I only getting one match?
The g flag is almost certainly off. Without it a regex stops at the first
match, which is the single most common surprise for people new to regular expressions.
Turn on global and the rest will appear.
Why does my pattern match nothing at the start of a line?
By default ^ means "start of the whole string" and $ means
"end of it", so a pattern anchored that way only ever matches once, at the very
beginning. Turn on multiline to make those anchors apply per line, which is
what you usually want when testing a list of values — every preset above that
validates one item per line uses it.
A note on catastrophic backtracking
Some patterns take exponentially longer as input grows. Nested quantifiers over
overlapping character sets — the classic shape is
(a+)+b — can make an engine try astronomically many combinations
before giving up, freezing whatever is running them. If a pattern seems to hang on a
longer test string, that is usually why. Rewriting it so the parts cannot match the same
characters fixes it.
This tool caps how many matches it will list so a pattern producing millions of results
cannot lock up the page, and it advances past zero-length matches so an expression like
a* terminates instead of looping.
Related tools
Once a pattern works, apply it with Find and Replace Text. For simpler text surgery there is Character Remover and Remove Line Breaks.
Last reviewed: August 2026