Regex Extractor
Extract all matches and capture groups from text using a regex pattern
/v1/regex-extract
curl -X POST "https://devtools.toolkitapi.io/v1/regex-extract" \
-H "Content-Type: application/json" \
-d '{"pattern": "(\\d{4})-(\\d{2})-(\\d{2})", "text": "Events on 2024-01-15 and 2024-03-20", "flags": ""}'
import httpx
resp = httpx.post(
"https://devtools.toolkitapi.io/v1/regex-extract",
json={"pattern": "(\\d{4})-(\\d{2})-(\\d{2})", "text": "Events on 2024-01-15 and 2024-03-20", "flags": ""},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/regex-extract", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({"pattern": "(\\d{4})-(\\d{2})-(\\d{2})", "text": "Events on 2024-01-15 and 2024-03-20", "flags": ""}),
});
const data = await resp.json();
console.log(data);
# See curl example
{
"pattern": "(\\d{4})-(\\d{2})-(\\d{2})",
"match_count": 2,
"matches": [
{"match": "2024-01-15", "start": 10, "end": 20, "groups": ["2024", "01", "15"], "named_groups": {}},
{"match": "2024-03-20", "start": 25, "end": 35, "groups": ["2024", "03", "20"], "named_groups": {}}
]
}
Try It Live
Description
How to Use
1. Send a POST with `pattern`, `text`, and optional `flags`.
2. Use capture groups `(...)` in your pattern to extract specific parts of each match.
3. Use named groups `(?P
4. All matches are returned — there's no need for a `g` flag.
About This Tool
Regex Extractor finds all matches of a regular expression pattern in your text and returns each match with its capture groups, named groups, and character positions. Unlike Regex Tester, this endpoint always operates in global mode — it returns every non-overlapping match.
Use it when you need to pull structured data out of unstructured text: dates from log lines, IPs from config files, tokens from HTML, etc.
Why Use This Tool
- Log parsing — Extract timestamps, IPs, or error codes from log lines
- Data mining — Pull structured values from unstructured text
- Content scraping — Extract URLs, emails, or phone numbers from text
- Migration scripts — Extract and transform values during data migrations
Frequently Asked Questions
How is this different from Regex Tester?
Can I use it without capture groups?
What regex flags are available?
Start using Regex Extractor now
Get your free API key and make your first request in under a minute.