Test regular expressions online

Run a regex against sample text and see every match with positions and capture groups.

Files stay local .txt Max 1MB
Files stay local

Options

This field is required — please fill it in

The expression itself; flags go in the field below.

g = find all; without g only the first match. Allowed: g i m s u y d.

What this tool does

This tester answers one concrete question: what does this regex actually match in this text? Paste the pattern (without / / delimiters) and a sample, and you get every match with its position, the matched text, and the content of each capture group.

Its biggest value shows up when things go wrong: an invalid pattern produces the exact error from the JavaScript engine — "unterminated group", "invalid escape" — with context, instead of a silent empty result you have to debug by squinting.

How to use

  1. Step 1: enter the pattern Enter the expression only, without the surrounding slashes: write \d+, not /\d+/. Flags (g, i, m…) go in their own field; g finds every match, and without it only the first one is listed.
  2. Step 2: paste sample text Paste the text you actually intend to process — logs, API responses, HTML fragments. The closer the sample is to real data, the more useful the result.
  3. Step 3: read the report The first line is the match count; each entry looks like [1] 0-11: "hello world", where the brackets are start and end offsets (end exclusive). Indented lines under each entry show $1, $2 and so on. When debugging stray empty matches, compare the offsets of adjacent entries.

Limits

Semantics are JavaScript RegExp, which is not identical to PCRE, Python or Go: named-group syntax, recursion and possessive quantifiers differ, so check the target language docs before porting. Input is capped at 1MB on purpose; replace and split previews are not offered, nor are syntax visualisation or backtracking counters. There is no timeout for matching itself — the 1MB cap plus the cancel button are the safety net.

FAQ

Why only the first match?

Because the g flag is missing. g means global (find every match); without it only the first is reported — matching JavaScript behaviour exactly, which is useful when you want to see what "no g" does.

What does an unmatched group show?

It shows "(not participating)". For example (x)?b matching "b" leaves the x group undefined, and the report marks that line accordingly.

Why does a valid-looking pattern fail to compile?

Common causes: keeping the surrounding slashes (/\d+ should be \d+), unescaped metacharacters (dot must be \.), or syntax JS does not support such as PCRE atomic groups. The error includes the engine message — read it directly.

Will a huge input freeze it?

Input is capped at 1MB and normal patterns (logs, API responses) finish in milliseconds. Catastrophic backtracking cannot be interrupted by the browser though — with a pattern like (a+)+ and the right input the worker keeps computing, so use the cancel button.

Are named capture groups supported?

Yes ((?<year>\d{4})); the report lists numbered and named groups, with named ones shown as $<year>. Portability note: PCRE spells them (?P<year>…), which is not identical.

Is my pattern or data sent anywhere?

No. Matching runs in a dedicated worker in the page, and no request carries your pattern or text — debugging intranet URLs or secret-shaped keys stays local.

Related tools