Regex Tester & Explainer

Test a regular expression against your own text, see every match highlighted as you type, and read back in plain English what the pattern actually does. Nothing leaves your browser.

//
Start from:
101 characters
3Matches
2Capture groups
61Characters matched

Frequently asked questions

Which regex flavour does this test?

JavaScript’s own RegExp engine, exactly as it behaves in a browser and in Node.js. Patterns that rely on PCRE, Python or .NET extensions — possessive quantifiers, atomic groups, recursion, K — are not supported here because they are not supported in JavaScript either.

What do the g, i, m, s, u and y flags do?

g finds every match rather than just the first, i ignores case, m makes ^ and $ match at each line rather than only at the ends of the text, s lets . match a newline, u turns on full Unicode handling and y anchors matching at the current position. Each flag is explained in place as you toggle it.

Why does my pattern only match once?

Because the g flag is off. Without it the engine stops at the first match — which is also what String.replace and RegExp.exec do — so a pattern that looks correct appears to miss later occurrences. The tool points this out and offers to add the flag for you.

How do I test a replacement?

Switch to the replace view and type the replacement string. Group references such as $1 and named references such as $<year> are substituted as String.replace would substitute them, so what you see is what your code will produce.

Why did matching stop partway through?

A pattern that backtracks catastrophically — typically nested quantifiers like (a+)+ over a long non-matching string — can run effectively forever. Matching is abandoned after 250 milliseconds so the page stays usable, and the warning is a real finding: the same pattern would hang your server, which is how regular-expression denial of service happens.

What does the explanation panel do?

It reads the pattern apart and describes each piece in plain English — what a character class covers, what a quantifier repeats, what a group captures — nested to match the structure. It is the fastest way to work out what an inherited pattern actually does before you change it.

Is the text I test against sent anywhere?

No. The whole tool is JavaScript running in your own browser, so nothing you type or paste is sent over the network, written to a log or attached to an analytics event. You can confirm it by opening the network tab and watching it stay empty while you work.