Regex Matcher Online – Find All Matches

Local only

Find every regular-expression match and inspect match indexes, captures, and named groups as structured JSON.

19 chars · 1 line

5 chars · 1 line

Pattern matched the inputFlags: g

Regex matching guide

How to find every regex match and capture group

Enter a JavaScript regular expression and sample text above, then choose Match All to enumerate each occurrence. The output includes matched text, zero-based indexes, numbered captures, and named groups when the pattern defines them. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • Match-all scanning
  • Zero-based match indexes
  • Numbered capture groups
  • Named capture groups
  • Zero-length match protection
  • Browser-local processing

Steps

  1. Enter a JavaScript regex pattern and the flags that control matching behavior.
  2. Paste text that contains one or more values you expect the pattern to find.
  3. Choose Match All and review each match index and capture group in the JSON output.
  4. Adjust the pattern until the match list includes only the intended text ranges.

Inspect match positions instead of guessing what was captured

Each result reports the full matched substring and the zero-based character index where it begins. That makes it easier to compare regex behavior with parser offsets, editor positions, and source text.

Debug numbered and named capture groups

Numbered groups are returned in capture order and unmatched optional groups appear as null. Named groups are exposed as a separate object so extraction code can be checked against the labels used by the pattern.

Match All adds a global scan when the user omitted g, but the stored flag string is left unchanged so Test and Replace modes still follow the flags you entered.

Handle zero-length regex matches safely

Patterns built from lookarounds or optional constructs can match an empty string. The matcher advances after a zero-length match so scanning cannot become stuck at the same position in a manual exec loop.

Regex capture example

A pattern extracts level and numeric code from two log tokens, returning each source index and both capture groups.

Pattern and log text

/(ERROR|WARN):(\d+)/g
ERROR:42 WARN:7

Structured matches

[
  { "match": "ERROR:42", "index": 0, "captures": ["ERROR", "42"] },
  { "match": "WARN:7", "index": 9, "captures": ["WARN", "7"] }
]

Common questions

Frequently asked questions

What index does Regex Matcher return?

It returns the zero-based JavaScript string index where each full match begins.

What happens when I omit the g flag?

Match All adds a global flag only for the scan so every occurrence can still be listed.

Are optional capture groups preserved?

Yes. An unmatched numbered capture is represented as null so the capture positions remain stable.

Debugging a specific Regex issue? Browse Regex troubleshooting.