Regex Extractor

Extract all matches and capture groups from text using a regex pattern

POST 1 credit /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
Response 200 OK
{
  "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

Live Demo

Description

Extract all matches and capture groups from text using a regex pattern

How to Use

1

1. Send a POST with `pattern`, `text`, and optional `flags`.

2

2. Use capture groups `(...)` in your pattern to extract specific parts of each match.

3

3. Use named groups `(?P...)` to get key-value pairs in `named_groups`.

4

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

Frequently Asked Questions

How is this different from Regex Tester?
Regex Extractor always returns all matches (global mode) and is focused on data extraction. Regex Tester supports single-match mode and includes a pattern explanation.
Can I use it without capture groups?
Yes. The `groups` array will be empty, but full matches are still returned with positions.
What regex flags are available?
`i` (case-insensitive), `m` (multiline — `^`/`$` match line boundaries), `s` (dotall — `.` matches newlines), `x` (verbose — allows comments in the pattern).

Start using Regex Extractor now

Get your free API key and make your first request in under a minute.