Dev Tools icon

Dev Tools

A suite of utility tools for developers: Generators, converters, and transformers.

Regex Named Extractor

AI-generated

Summary

Extract named capture groups from text using a user-defined regular expression with optional global matching.

Inputs

  • Text (required) — The input text string from which to extract data.
  • Regex (required) — A regular expression with named capture groups to apply on the text. E.g., '(?\w+)'.
  • Global — Boolean flag indicating whether to find all matches (true) or only the first match (false). Defaults to false.

Output shape

A JSON object containing extracted named groups. If Global is false, returns a single object with the named capture groups from the first match (or empty if none). If Global is true, returns an object with a 'results' key mapping to an array of named group objects for all matches.

If the regular expression is invalid, the operation will fail with an error. The regex should include named capture groups to extract meaningful results.

Examples

Example 1: Extract all named groups globally from a text

Set Text to the input string, Regex to a pattern with named groups, and Global to true. The output 'results' array contains all matched named groups objects.

Example 2: Extract the first match's named groups from a text

Set Text to the input string, Regex to a pattern with named groups, and Global to false (or omit). The output is a single object with named groups from the first regex match.

Links

Discussion