xtract.bot
POST /api/regex-test

Test a regex against an input string. Returns every match, the position, and any capture groups (named and numbered). Useful for debugging patterns.

Tests a regex pattern against the input and returns every match. For each match you get: - The matching substring. - The starting index in the input. - An array of capture-group values (`$1`, `$2`, …). - A map of named-group values (`?<name>` syntax). Pattern flags work the same way as in JavaScript: `g` (global, default — must be set to find more than the first match), `i` (case-insensitive), `m`, `s`, `u`.

Inputs

NameTypeDefaultDescription
pattern*stringRegex pattern (without slashes).
text*stringText to search.
flagsstring""Regex flags (e.g. `i`, `im`, `iu`). The `g` flag is always added.

Response

Modes: json. Cache: yes (24h TTL).

Code samples

Built from the emails example.


curl -X POST https://api.xtract.bot/api/regex-test \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "pattern": "([\\w.+-]+)@([\\w.-]+)",
  "text": "Contact alice@example.com or bob+spam@test.io for details.",
  "flags": ""
}'