Skip to content

String Match Regex

Finds the first regex match in a string and returns its captured groups.

This node searches for the first occurrence of a regular expression pattern within an input string.

Output#

The groups output is a list of strings containing the captured groups from the first match.

  • Capturing Groups: These are the parts of your pattern enclosed in parentheses ().
  • Exclusion of Full Match: The entire string that matches the pattern is not included in the output, only the captured groups are.
  • No Match: If the pattern does not match the string, the output is an empty list.
  • No Capturing Groups: If the pattern matches but contains no capturing groups (e.g., no ()), the output is also an empty list.

Example#

  • Input String: File: image_001.jpg
  • Pattern: (\w+)_(\d+)\.(\w+)
  • Output groups: ["image", "001", "jpg"]

The node uses Go's standard regexp engine. For more details on the supported syntax, see the Go regexp syntax documentation.

Inputs#

Port Description
Input
The string to search.
Regex
The regular expression pattern.

Outputs#

Port Description
Groups
A list of captured groups from the first match.

ID: core/string-match-regex@v1