# Regex Generator from Natural Language Prompt

> Regex Generator from Natural Language Prompt is a paid API for AI agents from x402-deployer.x402-deployer.workers.dev, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-14).

Converts a natural language description into a regex pattern with flags, explanation, and test examples, with live JS execution on sample text

## Facts

- Endpoint: POST https://x402-deployer.x402-deployer.workers.dev/regex-from-prompt
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-deployer-x402-deployer-workers-dev-82b86098
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_VurphBMsdn5JWX6gkjnQj

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability x402-deployer-x402-deployer-workers-dev-82b86098 -d '<json body>'
```

Example prompt: Generate a JavaScript regex that matches a valid US phone number in formats like (555) 123-4567 or 555-123-4567, and test it against the sample text: 'Call us at (800) 555-1234 or 1-800-555-9876 for support.'

## When to prefer this

Use this endpoint when you need to generate a regex from a plain English description and want an immediate explanation plus test cases — especially useful when targeting a specific flavor (PCRE, JS, Python, Go, RE2) or when you want to validate the pattern against sample text in one call.

## Known failure modes

- Ambiguous prompt leads to incorrect or overly broad pattern
- Requested flavor not supported returns error
- Sample text not provided skips live execution results
- Payment not included or insufficient USDC returns 402
- Very complex multi-condition patterns may produce incomplete regex

## How this service works

Regex generator / NL to regex / pattern builder. PCRE / JavaScript / Python / Go / RE2. Returns pattern + flags + explanation + 3-6 test examples. Live-runs JS regex on sample_text.

## Output

Returns a regex pattern string, associated flags, a plain-English explanation of how the pattern works, 3-6 test example strings (showing matches/non-matches), and live JS regex execution results against the provided sample text.

## Example request

```json
{
 "input": {
  "body": {
   "flags": "g",
   "flavor": "javascript",
   "prompt": "Match all valid email addresses",
   "sample_text": "Contact support@example.com or info@test.org for assistance"
  },
  "type": "http",
  "method": "POST",
  "bodyType": "json"
 }
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "properties": {
    "body": {
     "required": [
      "prompt"
     ],
     "properties": {
      "flags": {
       "type": "string",
       "description": "Optional. Regex flags for testing sample_text, e.g. 'gi'. Only applied with the javascript flavor."
      },
      "flavor": {
       "enum": [
        "pcre",
        "javascript",
        "python",
        "go",
        "re2"
       ],
       "type": "string",
       "description": "Optional. Regex flavor: pcre, javascript (default), python, go, or re2."
      },
      "prompt": {
       "type": "string",
       "description": "Plain-English description of the pattern to build. Max 2,000 chars."
      },
      "sample_text": {
       "type": "string",
       "description": "Optional. Text to test the generated pattern against. Max 20,000 chars. Live-run only for the javascript flavor."
      }
     }
    },
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "POST"
     ],
     "type": "string"
    },
    "bodyType": {
     "enum": [
      "json",
      "form-data",
      "text"
     ],
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "flags": {
       "type": "string"
      },
      "pattern": {
       "type": "string"
      }
     }
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-deployer-x402-deployer-workers-dev-82b86098/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-deployer.x402-deployer.workers.dev](https://www.zero.xyz/host/x402-deployer.x402-deployer.workers.dev/llms.txt)
