#496 · Developer Tool

Regex Match Extractor

Run a JavaScript regular expression against text and extract every match with its index and capture values. The tool safely adds global iteration when needed, handles zero-length matches without looping forever, and exports structured rows for debugging parsers, log searches, and migration scripts.

Developer Input

Regex Match Extractor
Ad space

How to use this developer tool

  1. Enter the source text.
  2. Provide a JavaScript pattern without slash delimiters and choose flags.
  3. Extract matches and review positions plus numbered captures.
  4. Export rows when the results need further analysis.

What this developer tool does

Each line lists the full match, its zero-based index, and any captured substrings.

Compile the JavaScript RegExp, iterate with exec, record indices and capture arrays, and advance manually after empty matches.

Regular expressions are code-like input; avoid testing unknown complex patterns against large text.

Example

Pattern: #[0-9a-f]{6}
Text: Colors #aabbcc and #112233
Matches: two hex values

Use cases

  • Extract IDs from logs.
  • Prototype scraping expressions.
  • Audit capture group contents before coding.

Tips for reliable output

  • Do not include / delimiters.
  • Use the u flag for Unicode-aware patterns.
  • Anchor patterns when boundaries matter.
  • Start with small input for unfamiliar patterns.

Processing details

If g is absent it is added for extraction while other supplied flags are preserved. Indices refer to UTF-16 code-unit offsets used by JavaScript.

The browser engine determines supported syntax. Lookbehind and newer flags may not exist in older browsers.

Frequently asked questions

Which regular expression syntax is supported?

Patterns use the JavaScript regular expression engine available in your browser.

What happens when the pattern is invalid?

The tool reports the JavaScript syntax error and does not process the input text.

Can a regular expression freeze the page?

Pathological patterns can cause catastrophic backtracking. Test untrusted patterns on small input first.

Are matches evaluated by Unicode code point?

Only when the Unicode-related flag and pattern semantics call for it; otherwise JavaScript uses UTF-16 code units.

Does the tool send pattern or text to a server?

No. Matching and replacement run in the current browser tab.

Output fields

FieldMeaning
SummaryHigh-level processing result
StatisticsCounts and validation details
ExportCopy-ready text plus structured data when available

Code Formatting & Regex tools

Browse more tools for code formatting & regex.

Open category hub