Skip to main content

Description

Extracts all matches and capture groups from a string using a regular expression pattern. Returns a nested array where each match contains the full match and any captured groups.

Syntax

Parameters

Returns

Type: list of lists A nested array where each inner array represents one match and contains the full match followed by any capture groups. Returns null if input string is null.

Examples

Example 1: Extract Email Components

Output:

Example 2: Parse Date Components

Output:

Example 3: Extract URLs and Protocol

Notes

  • Returns null if input string is null
  • The regex is applied globally (finds all matches)
  • Each match array contains: [fullMatch, group1, group2, …]
  • Useful for parsing structured text, extracting data patterns
  • More powerful than simple string search for complex patterns

See Also

Frequently Asked Questions

Each inner array contains the full match at index 0, followed by capture groups at index 1, 2, etc. For example: [['john@ex.com', 'john', 'ex.com']].
It finds all matches in the string (global matching), returning one inner array per match.