Trexmi
Developer Ready

Regex Extractor

Extract all regex matches and capture groups from text.

Full-match extraction Numbered capture-group selection Occurrence numbers and source offsets Optional unique-value filtering
INPUT Records to extract from *
0 chars0 words0 lines
Paste records, logs, or notes containing the values you want to collect into a structured list. Example: order=API-2048 version=2.4.1 order=WEB-7315 version=2.4.1

Tool settings

Quick presetsNo regex knowledge required

Choose what you want to find or split. Trexmi fills the pattern and flags automatically; advanced users can edit the regex afterwards.

Match the records to collect. Choose group 0 for complete matches or a numbered capture group for one field.
Ctrl / ⌘ + Enter
Extracted matches JSON list containing selected values, occurrence numbers, and source byte offsets.
About the tool

What Regex Extractor does

Regex Extractor collects data from text instead of rewriting it. The tool finds every PCRE match and returns either the complete match or one numbered capture group as a structured JSON list.

Choose group 0 when the exact text matched by the pattern is the desired value. Choose group 1 or later when the expression needs surrounding context but only one captured field should be returned. Every output row includes an occurrence number and the byte offset of that selected value in the original source.

The Unique values option removes repeated values from the final list. This page is designed for collection and export; use Regex Tester PRO for detailed group diagnostics and Regex Replace when the source itself must be transformed.

Regex match extraction with capture group selection and source offsets
Collect complete matches or one selected field and trace each value to its source location.

How to use

  1. Add source records. Paste representative logs, notes, exports, or semi-structured lines.
  2. Define the extraction pattern. Use boundaries so adjacent punctuation does not enter the result.
  3. Choose a capture group. Select 0 for full matches or the numbered group containing only the needed field.
  4. Handle duplicates. Keep every occurrence for traceability or enable unique output for a distinct list.
  5. Validate the collection. Check the returned count, values, and offsets before importing the data elsewhere.
Built for the task

Why use Regex Extractor?

Focused controls, predictable output, and a workflow designed around this exact transformation.

01

Collection-first output

Receive a JSON list of matching values rather than an altered copy of the source.

02

Selected-field extraction

Return a complete match or isolate one numbered capture group from surrounding context.

03

Traceable occurrences

Use match numbers and source offsets to locate each extracted value in the original input.

04

Optional deduplication

Preserve repeated occurrences or collapse them to the first unique value.

Useful answers

Questions about Regex Extractor

Practical details about input, output, privacy, limits, and the best way to use this tool.

01 What does Regex Extractor return?

It returns JSON containing the selected group number, extraction count, and a list of values with occurrence numbers and source offsets.

02 What is capture group 0?

Group 0 is the complete regex match. Groups 1–99 refer to numbered parenthesized captures inside the pattern.

03 When should I select group 1?

Select group 1 when surrounding labels or delimiters help find a record but only the captured field should appear in the output.

04 What does Unique values only do?

It removes later duplicate values while preserving the first occurrence and its source offset.

05 Are offsets character positions?

The extractor currently reports byte offsets. UTF-8 characters can occupy more than one byte, so use Regex Tester PRO when Unicode character, line, and column positions are needed.

06 Can I extract named groups?

The extraction selector accepts numbered groups. Use Regex Tester PRO when you need a detailed named-group report.

07 Does a match prove that the value is valid?

No. Validate calendar dates, addresses, identifiers, and other business data after extraction.

08 Can a regex extraction be slow?

Yes. Avoid ambiguous alternatives and nested quantifiers, limit source size, and test long nonmatching input.

Learn Regex

Read the complete Regex Guide

Understand regex syntax, character classes, groups, quantifiers, flags, practical examples, and common mistakes.

  • Regex syntax and patterns
  • Groups, flags, and quantifiers
  • Debugging and best practices
Read guide Practical explanations and examples

Examples

Collect order IDs only

The label helps locate each record while group 1 returns only the identifier.

Input
Text:
order=API-2048 status=paid
order=WEB-7315 status=pending
Pattern: \border=([A-Z]{2,5}-\d{3,8})\b
Group: 1
Output
API-2048
WEB-7315

Extract distinct versions

Duplicate captured values collapse to their first occurrence.

Input
Text:
version=2.4.1
Version: v2.4.1
version=3.0
Pattern: \bversion[=: ]+v?(\d+(?:\.\d+){1,3})\b
Group: 1
Unique: yes
Output
2.4.1
3.0

Return complete dates

Group 0 returns every complete match.

Input
Text: Start 2026-09-04, finish 2026-09-18
Pattern: \b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b
Group: 0
Output
2026-09-04
2026-09-18

Turn matching text into a structured list

Regex Extractor scans the source for repeated records and emits only the chosen values. It does not include the complete diagnostic tree produced by Regex Tester and it does not create transformed prose like Regex Replace. The result is intentionally compact: selected group, count, match number, value, and source offset.

This workflow fits log identifiers, version numbers, dates, URLs, email-like strings, reference codes, and labels in semi-structured exports. Regex works best when every desired token has a repeatable boundary.

Examples for extracting regex matches

Collect all email-like values

Pattern: \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b
Flags: iu
Group: 0

Return only order identifiers after a label

Pattern: \border=([A-Z]{2,5}-\d{3,8})\b
Input: order=API-2048 status=paid
Group: 1
Output value: API-2048

Collect distinct software versions

Pattern: \bversion[=: ]+v?(\d+(?:\.\d+){1,3})\b
Flags: iu
Group: 1
Unique values: enabled

Extract ISO-shaped dates

Pattern: \b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b
Group: 0

Collect the value inside quoted ID fields

Pattern: \bid=["']([^"']+)["']
Group: 1

Complete matches versus selected groups

Use group 0 when boundaries are excluded from the pattern and the full match is already clean. Use a numbered group when a stable label such as order= is needed to locate the value but should not be exported. Non-capturing parentheses (?:...) organize a pattern without increasing the group number.

If the selected group does not exist, the tool stops with a clear error. If an optional group does not participate in a particular match, that row is skipped. Test every alternative branch so the chosen group remains present and meaningful.

Duplicates, occurrence numbers, and offsets

Keep duplicates when each occurrence matters, such as repeated events in a log. Enable unique values for a compact set of domains, identifiers, or versions. Deduplication preserves the first occurrence, so its offset still points to a real location in the source.

Offsets are measured in UTF-8 bytes. For human-facing Unicode character offsets, line numbers, and columns, open the same expression in Regex Tester PRO. A byte offset is still useful for server-side processing and tracing values back into the exact source payload.

Validate extracted values after collection

A regular expression can confirm shape without confirming meaning. An ISO-shaped date can still name a nonexistent calendar day, an IPv4-shaped candidate can contain an invalid octet if the pattern is broad, and an email-like value can reference no working mailbox. Apply domain validation before database import or automation.

Compare the returned count with an expected range. An unexpectedly large count often means a permissive boundary or an empty-string-capable expression. Review the PHP preg_match_all reference and PCRE2 documentation for engine behavior.

Related Trexmi tools

Inspect every group and position with Regex Tester PRO, generate a starting expression with Regex Builder, or modify matching source text with Regex Replace.