Skip to content

Regex Tester

Test JavaScript regular expressions live: highlight matches, see indexes and capture groups, toggle g, i, m, s, u, y flags and get clear syntax errors.

Developer Runs client-side Free to use
Jump to the tool
Share: X WhatsApp
Loading Regex Tester…

About the Regex Tester

Regex Tester runs your regular expression against sample text using the JavaScript RegExp engine built into your browser. Matches are highlighted in place and listed with their index positions, lengths and capture groups, including named groups.

Each flag — g, i, m, s, u and y — can be switched on or off, and any flag your browser does not support is disabled. Invalid patterns show the browser’s own syntax-error message, and patterns that run for too long are stopped automatically instead of freezing the page.

Because the test uses JavaScript (ECMAScript) rules, results match what you will see in browser and Node.js code. Other engines such as PCRE, Python or Java can behave differently.

How to use

  1. Type your pattern into the field between the slashes — without the surrounding / characters.
  2. Tick the flags you need; g is on by default so all matches are found.
  3. Paste or type the text to test in Test text. Results update as you type.
  4. Read the match count, the highlighted text and the match details with index positions and groups.
  5. Copy the regex as a /pattern/flags literal or download the matches as a CSV. Try a preset if you need a starting point.

Key features

  • Uses the browser’s native JavaScript RegExp engine — no server and no third-party regex library.
  • Live highlighting built from text nodes, so test text is never interpreted as HTML.
  • Match list with index, length, numbered capture groups and named groups.
  • Flag toggles for g, i, m, s, u and y with automatic detection of unsupported flags.
  • Runs in a background worker with a 2-second timeout to catch catastrophic backtracking.
  • Presets for email, URL, phone number, digits-only lines, hexadecimal values and ISO dates.

Best practices

  • Anchor patterns with ^ and $ (and the m flag for line-by-line checks) when the whole value must match, not just part of it.
  • Prefer specific character classes such as [0-9] or [A-Za-z] over .* to keep patterns fast and predictable.
  • Avoid nested quantifiers like (a+)+ that can trigger catastrophic backtracking on long inputs.
  • Test with both valid and invalid sample lines so you can see what the pattern rejects as well as what it accepts.
  • Treat the presets as starting points — real validation of emails or phone numbers usually needs more than a single regex.

Benefits

  • Faster debugging than adding console.log statements to your code.
  • Exactly the same behaviour you will get in JavaScript, because it is the same engine.
  • Your test data stays in the browser, which matters for logs and customer data.
  • Clear error messages help when learning regex syntax.

Frequently asked questions

Which regex flavour does this tester use?

JavaScript (ECMAScript), as implemented by the browser you are using. It is the same engine used by RegExp in your front-end code and, for most features, by Node.js.

Why does my PCRE or Python pattern fail here?

Some syntax from other engines is not part of JavaScript regex, such as possessive quantifiers (a++), atomic groups (?>…) or inline modifiers like (?i). Rewrite those parts using JavaScript-compatible syntax.

Why do I only see one match?

Without the g (global) flag, JavaScript returns only the first match. Turn on g to find all matches.

What does “Stopped after 2 seconds” mean?

The pattern took too long on your text — usually a sign of catastrophic backtracking from nested or overlapping quantifiers. The test is stopped so the page stays responsive; simplify the pattern and try again.

Is my test text sent anywhere?

No. Matching runs in a Web Worker inside your browser tab. Nothing is uploaded or stored.

How are empty matches shown?

Zero-length matches (for example from ^ or \b on their own) appear as a thin red marker in the highlighted text and as “(empty string)” in the match list.