Regex Tester

Runs in browser Utilities

Write a JavaScript regular expression, toggle flags (g, i, m, s, u, y), and see every match, named and numbered groups, indexes and a replacement preview instantly. Includes a quick reference of tokens.

Privacy: This tool runs entirely in your browser. Your input never leaves your device.
Loading tool…

How to use Regex Tester

  1. Type a JavaScript regular expression in the pattern box (or click "Load example").
  2. Paste the text to test; matches are highlighted instantly and listed in the table.
  3. Toggle flags such as i (ignore case) or m (multiline) to see how the results change.
  4. Optionally enter a replacement string to preview a find-and-replace.
  5. Copy the matches as CSV or download the replaced text.

Regex Tester features

  • Live matching as you type, with every match highlighted in the text
  • Table of matches with index, end position, line:column and every numbered or named group
  • Flags g, i, m, s, u and y as one-click toggles; regex literals like /abc/gi are accepted
  • Replacement preview supporting $1, $<name>, $& and $$
  • Static detection of catastrophic-backtracking patterns and a time budget so the page never hangs
  • Clear, professional syntax errors with a hint about the likely cause

Regex Tester example

Extract user and domain from email addresses

Input:

Pattern: (?<user>[\w.+-]+)@(?<domain>[\w-]+\.[a-z]{2,})
Text: layla@example.com, omar.said@mutqan.sa

Output:

#1 layla@example.com  index 0  user=layla  domain=example.com
#2 omar.said@mutqan.sa  index 19  user=omar.said  domain=mutqan.sa

Frequently asked questions about Regex Tester

Which regex flavour does the tester use?

JavaScript (ECMAScript) regular expressions as implemented by your browser — the same engine used by Node.js, Deno and browser code. Most patterns from PCRE, Python and Java work unchanged; lookbehind, named groups and \p{…} Unicode classes are supported.

Why is only the first match shown?

Without the g (global) flag a regex stops at the first match. Enable the g checkbox to list every match; it is on by default.

How do I reference groups in the replacement?

Use $1, $2 for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign — exactly like String.prototype.replace in JavaScript.

What happens with slow or catastrophic patterns?

The tool statically detects nested unbounded quantifiers such as (a+)+ and refuses to run them on large text. Execution is also time-boxed so the page never freezes.

Is my text uploaded anywhere?

No. Matching runs entirely in your browser; nothing is sent to a server.

Technical notes

The tester compiles your pattern with the browser's native RegExp engine and iterates matches with exec(), advancing lastIndex manually on empty matches to avoid infinite loops. A small parser analyses the pattern tree for nested unbounded quantifiers and overlapping alternations — the classic sources of exponential backtracking — and refuses to run risky patterns on inputs above 2,000 characters.

Positions are reported in UTF-16 code units, exactly as JavaScript String methods do, so indexes can be used directly in slice() calls.