# Regex tester

Test a regular expression against text and see every match with its position and groups.

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

## 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).

## Example 1

```json
{"input":{"pattern":"(?P<year>\\d{4})-(\\d{2})","text":"From 2024-01 to 2025-12"}}
```

Result:

```json
{"matched":true,"count":2,"truncated":false,"matches":[{"match":"2024-01","start":5,"end":12,"groups":["2024","01"],"named":{"year":"2024"}},{"match":"2025-12","start":16,"end":23,"groups":["2025","12"],"named":{"year":"2025"}}]}
```

## Example 2: Ignoring case

```json
{"input":{"pattern":"^hello","text":"Hello there","flags":"i"}}
```

Result:

```json
{"matched":true,"count":1,"truncated":false,"matches":[{"match":"Hello","start":0,"end":5,"groups":[],"named":{}}]}
```

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

**How are positions counted?** "start" and "end" count characters from 0. "end" is the position just after the match.

**Why is a group null?** That group is optional and took no part in the match.
