Navigation
POST text

regex_extract

1 credit

Extract regex matches from text

Endpoint

POST /api/v1/tools/text/regex_extract

Body Parameters

text string required
pattern string required

Example

input Request
{
    "text": "Call 555-1234 or 555-5678",
    "pattern": "(\\d{3})-(\\d{4})"
}
output Response
{
    "count": 2,
    "matches": [
        {
            "end": 13,
            "match": "555-1234",
            "start": 5,
            "groups": [
                "555",
                "1234"
            ]
        },
        {
            "end": 25,
            "match": "555-5678",
            "start": 17,
            "groups": [
                "555",
                "5678"
            ]
        }
    ]
}

Response Format

HTTP/1.1 200 OK SUCCESS
{
  "success": true,
  "data": {
    "count": 2,
    "matches": [
        {
            "end": 13,
            "match": "555-1234",
            "start": 5,
            "groups": [
                "555",
                "1234"
            ]
        },
        {
            "end": 25,
            "match": "555-5678",
            "start": 17,
            "groups": [
                "555",
                "5678"
            ]
        }
    ]
},
  "meta": {
    "tool": "regex_extract",
    "credits_consumed": 1
  }
}
HTTP/1.1 422 Unprocessable Entity ERROR
{
  "success": false,
  "data": null,
  "error": {
    "code": "validation_error",
    "message": "The given data was invalid."
  }
}

Sign in to try this tool directly from the docs.

Code Examples
Request Example
lightbulb Developer Tip

Credits are deducted before execution. If the upstream tool fails, credits are automatically refunded to your account.