regex_extract
Extract matching patterns from text using regular expressions. Returns a JSON array of matches with full match and capture groups.
Instructions
Run a regular expression against text and return all matches. Supports capture groups, named groups, and multiline input. Returns a JSON array of match objects — each has match (full match) and groups (array or object for named groups). Returns an empty array if no matches are found. Returns an error if the pattern is not a valid regular expression. Has no side effects. Free. Use for extracting emails, URLs, codes, patterns, or any structured data from unstructured text.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The text to search. | |
| flags | No | Regex flags string (default "gi"). Common: g=global, i=case-insensitive, m=multiline, s=dotAll. | |
| pattern | Yes | Regular expression pattern (without delimiters). | |
| maxMatches | No | Max matches to return (default 100, max 500). |