Regex extractor

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

Input

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

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/regex-extract \
  -H 'Content-Type: application/json' \
  -d '{"input":{"pattern":"#(\\d+)","text":"Fix #123 and #456, see #123","group":"1","unique":true}}'
import json, urllib.request

body = {'input': {'pattern': '#(\\d+)', 'text': 'Fix #123 and #456, see #123', 'group': '1', 'unique': True}}
request = urllib.request.Request("https://setget.net/v1/tools/regex-extract", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/regex-extract", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"pattern":"#(\\d+)","text":"Fix #123 and #456, see #123","group":"1","unique":true}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "regex-extract",
  "input": {
    "pattern": "#(\\d+)",
    "text": "Fix #123 and #456, see #123",
    "group": "1",
    "unique": true
  }
}
{
  "input": {
    "pattern": "#(\\d+)",
    "text": "Fix #123 and #456, see #123",
    "group": "1",
    "unique": true
  }
}

Endpoint: POST /v1/tools/regex-extract. Over MCP: run_tool with slug: "regex-extract". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

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

Examples

Input
{
  "pattern": "#(\\d+)",
  "text": "Fix #123 and #456, see #123",
  "group": "1",
  "unique": true
}
Result
{
  "matches": [
    "123",
    "456"
  ],
  "count": 2,
  "truncated": false
}

Whole matches

Input
{
  "pattern": "\\b\\w+@\\w+\\.\\w+",
  "text": "[email protected], [email protected]"
}
Result
{
  "matches": [
    "[email protected]",
    "[email protected]"
  ],
  "count": 2,
  "truncated": false
}

Questions

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.