validate_regex
Validate a regex pattern by testing it against a string, returning match positions, capture groups, and named groups. Use flags and max matches to control results.
Instructions
Test a regex pattern against a string and return all matches.
Compiles the pattern with optional flags, then returns every match with its start/end positions, capture groups, and named groups.
Args: pattern: The regex pattern to compile (e.g. r"\d+") test_string: The string to match against flags: Optional list of flag letters: "i" (ignore case), "m" (multiline), "s" (dotall), "x" (verbose) max_matches: Maximum number of matches to return, 1–200 (default 50)
Returns: dict with keys: valid_pattern, pattern, is_match, match_count, first_match, matches (list with start/end/groups), cost_usd
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flags | No | ||
| pattern | Yes | ||
| max_matches | No | ||
| test_string | Yes |