# Regex extractor

Pull every match of a regular expression out of text as a simple list, or just one capture group.

- Endpoint: `POST https://setget.net/v1/tools/regex-extract` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `regex-extract`
- Page: https://setget.net/tools/regex-extract

## Inputs

- `pattern` (required, string): The regular expression (Python syntax).
- `text` (required, string): The text to search.
- `flags` (optional, string, default `""`): Letters that switch options on: i (ignore case), m (^ and $ match at each line), s (dot matches line breaks), x (allow spaces and comments).
- `group` (optional, string, default `"0"`): Capture group to return, by number or name. 0 is the whole match.
- `unique` (optional, boolean, default `false`): Return each distinct value once, in order of first appearance.

## Example 1

```json
{"input":{"pattern":"#(\\d+)","text":"Fix #123 and #456, see #123","group":"1","unique":true}}
```

Result:

```json
{"matches":["123","456"],"count":2,"truncated":false}
```

## Example 2: Whole matches

```json
{"input":{"pattern":"\\b\\w+@\\w+\\.\\w+","text":"sam@example.com, alex@example.org"}}
```

Result:

```json
{"matches":["sam@example.com","alex@example.org"],"count":2,"truncated":false}
```

**Which regex syntax is this?** Python's. It is close to PCRE and JavaScript, with named groups written (?P<name>...).

**Is there a limit?** The first 10,000 matches are returned. "truncated" is true when there were more.
