Skip to content
FreeToolsKit.app

Regex Tester & Explainer

Test a JavaScript regular expression against your own text. Matches are highlighted in place, each match lists its position and capture groups (numbered and named), and a plain-English explanation breaks the pattern down piece by piece. It uses your browser's real JavaScript engine in a background worker, so results match what RegExp does in your code, and a slow pattern is stopped after 2 seconds instead of freezing the page.

  • Free to use
  • No account required
  • Pattern and text stay on your device

Regex Tester & Explainer

Loading tool…

Was this tool helpful?

Good to know

Useful for
Debugging a pattern before putting it in code, extracting values such as numbers, dates or IDs from text, checking capture groups for a replace, learning regex syntax with real feedback, and finding out why a pattern is slow. To clean or format data first, try the JSON Formatter, Validator & Minifier (/text/json-formatter) or count text with the Word & Character Counter (/text/word-counter).
Accepts
A JavaScript regex pattern up to 2,000 characters, flags (d, g, i, m, s, u, v, y) and test text up to 100,000 characters
Produces
Highlighted matches, match details with capture groups, a plain-English explanation, the regex as a JavaScript literal, and a JSON download (regex-matches.json)

Privacy

The pattern and text you enter are tested in a background worker on your device. They aren't uploaded, sent to an AI service, saved in your browser or added to the page address. (Loading the page itself, like any website, still uses the network.)

Limitations

  • It tests JavaScript (ECMAScript) regular expressions only. PCRE, Python, Java and .NET support different syntax — possessive quantifiers, atomic groups and inline flags such as (?i) at the start may be rejected or behave differently.
  • Each test stops after 2 seconds. A timeout is a processing limit, not proof the pattern is wrong; it usually means catastrophic backtracking on this text.
  • Up to 500 matches and 50 capture groups per match are shown. Beyond that the tool says “Showing the first 500 matches” rather than giving a total.
  • Positions are UTF-16 code units, as in JavaScript: an emoji usually counts as 2.
  • Long capture values are shown, copied and downloaded as their first 200 characters (marked as cut off), with exact positions and lengths.
  • The explanation covers common syntax. Inline modifiers, v-flag set operations and legacy escapes are marked “Not explained by this tool” — the matches still come from the real engine.
  • Which flags and features work depends on your browser version; unsupported ones are reported, never silently changed.

Tips

  • Add the g flag to see every match; without it, JavaScript returns only the first one.
  • Use named groups such as (?<year>\d{4}) so the results are easier to read.
  • If a test times out, look for nested quantifiers like (a+)+ or (.*)* and make the inner part more specific.
  • Turn on d to see where each group starts and ends, which is handy before writing a replacement.

How to test a regular expression

  1. Type a pattern without the surrounding slashes, or paste a literal such as /ab+c/gi and choose Use pattern.
  2. Tick the flags you need: g finds every match, i ignores case, m makes ^ and $ work per line, s lets the dot match line breaks, u or v enables Unicode features, y makes matching sticky and d adds group positions.
  3. Paste or type the test text. The test runs automatically as you type; select Run test (or press Enter in the pattern) to run it straight away.
  4. Read the highlighted matches and the match details: start and end positions, length, and each capture group. Unmatched optional groups say not matched, which is different from an empty string.
  5. Check the explanation, then copy the regex, the matched text or a summary, or download the results as JSON.

Frequently asked questions

What does a regex tester do?

It runs a regular expression against sample text and shows what matches. This tool highlights each match, lists its start and end positions and capture groups, and explains the pattern in plain English, so you can fix a pattern before using it in code.

Which regex flavor does this tool use?

JavaScript (ECMAScript), using your browser's own RegExp engine — the same one your JavaScript code uses in that browser. Patterns written for PCRE, Python, Java or .NET can behave differently or be rejected.

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

g finds all matches; i ignores letter case; m makes ^ and $ match at line starts and ends; s lets the dot match line breaks; u treats text as Unicode code points and enables \p{…}; v is a newer Unicode mode with set operations (it can't be combined with u); y (sticky) only matches at the current position; d adds start and end positions for capture groups.

Why does my regex find only one match?

Without the g (global) flag, JavaScript returns only the first match. Tick g to find every match. With the sticky flag y, matching also stops as soon as the next match doesn't start exactly where the previous one ended.

What's the difference between a group that didn't match and an empty capture?

An optional group that didn't take part in the match is undefined in JavaScript, shown here as “not matched”. A group that matched zero characters is an empty string, shown as empty string "". Your code may treat them differently.

Why was my test stopped after 2 seconds?

Some patterns take extremely long on certain text because the engine tries a huge number of combinations — catastrophic backtracking, which can also be used for denial-of-service attacks (ReDoS). The test runs in a background worker that is shut down after 2 seconds, so the page stays responsive. It doesn't mean the pattern is invalid; make the pattern more specific, for example by avoiding nested quantifiers such as (a+)+.

Why are the positions different from the number of characters I see?

JavaScript counts positions in UTF-16 code units. Most characters are one unit, but emoji and some other characters are two, so positions after them are larger than the number of visible characters.

Are my regex pattern and test text uploaded or saved?

No. The pattern and text are tested in a background worker in your browser. They aren't sent to a server or AI service, aren't saved in browser storage and aren't put in the page address. Reloading the page clears them.