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. Returnsnull if input string is null.
Examples
Example 1: Extract Email Components
Example 2: Parse Date Components
Example 3: Extract URLs and Protocol
Notes
- Returns
nullif input string isnull - 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
- text.replace - Replace text using regex
- text.indexOf - Find simple substring position
- text.indexesOf - Find all substring positions
Frequently Asked Questions
What does the nested array structure look like?
What does the nested array structure look like?
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']].Does regexGroups find all matches or just the first?
Does regexGroups find all matches or just the first?
It finds all matches in the string (global matching), returning one inner array per match.