Regex Tester

Test regular expressions live with match highlighting, capture groups and a replace preview.

Write the pattern without the surrounding slashes — JavaScript (ECMAScript) syntax.

Flags
Quick patterns:

Enter a pattern above to see matches highlighted here.

Replace preview

Regex cheat sheet
.
any character except a newline
\d \w \s
digit, word character, whitespace
\D \W \S
the negated versions of the above
[abc] [^abc]
one of / none of these characters
a* a+ a?
zero or more, one or more, optional
a{2,4}
between 2 and 4 times
a+?
lazy quantifier — match as little as possible
^ $
start / end of the string (or line with the m flag)
\b
word boundary
(abc)
capture group — read back as $1
(?<year>\d{4})
named capture group
(?:abc)
group without capturing
a|b
either a or b
(?=abc) (?!abc)
positive / negative lookahead
No uploads. Your files stay on your device.

Free forever, no sign-up, no cookies. Buy me a coffee

How it works

Type a pattern, pick your flags and paste the text you want to check — the regex tester compiles your expression with the browser's own JavaScript engine and highlights every match instantly, so what you see here is exactly what String.prototype.match and replace will do in your own code. The match details list shows the index of each match plus every numbered and named capture group, and the replace preview lets you try substitution strings such as $1 or $& before you ship them. If the pattern does not compile you get the engine's real error message instead of a silent failure.

Everything runs 100% in your browser: your pattern and your test data are never uploaded, which makes it safe to debug expressions against logs, customer records or production snippets. Note that a runaway pattern (nested quantifiers such as (a+)+$ on a long string) can make any regex engine — including this one — hang for a while; shorten the test string if the page stops responding.

Frequently asked questions

How do I test a regular expression online?

Type your pattern into the pattern box without the surrounding slashes, tick the flags you need, then paste your text into the test string box. Every match is highlighted as you type and listed underneath with its index and capture groups — there is no button to press.

Which regex flavour and flags does this regex tester support?

It compiles your pattern with your browser's own JavaScript (ECMAScript) engine, so the g, i, m, s, u and y flags all work, along with named capture groups, lookahead and lookbehind. What you see here is exactly what match() and replace() will do in your own code.

Is it safe to test a regex on sensitive data?

Yes. Your pattern and your test string never leave your device — the expression is compiled and run entirely in the browser, with no upload and no logging — so you can safely debug patterns against server logs, customer records or production snippets.

Report a bug