Regex extractor
Pull every match of a regular expression out of text as a simple list, or just one capture group.
Input
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
| Name | Type | Required | What 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.
Related tools
- Regex testerTest a regular expression against text and see every match with its position and groups.
regex-test - Regex replaceReplace every match of a regular expression, with backreferences such as \1 in the replacement.
regex-replace - Extract emails and URLsPull every email address and web link out of a text, and optionally IPv4 addresses and hashtags.
extract-emails-urls - Apply a patchApply a unified diff to a text and get the patched result, with clear errors when a hunk does not fit.
patch-apply - Case converterConvert text between lower, UPPER, Title, Sentence, camelCase, PascalCase, snake_case, kebab-case and more.
case-convert - Escape and unescape textEscape or unescape text for HTML, URLs, JSON strings, shell commands, regular expressions and CSV fields.
escape-unescape