# x402-tools Regex From Examples

> x402-tools Regex From Examples is a paid API for AI agents from x402.nichospt.net, paid per call via x402, $0.005/call, status unknown (last checked 2026-10-11).

Generates a regular expression that matches given example strings and optionally rejects specified strings, supporting JS, PCRE, and Python flavors.

## Facts

- Endpoint: POST https://x402.nichospt.net/regex-from-examples?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-tools-regex-from-examples-3901c8c0
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_aNnSGi770bTSi8fUMNFSW

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-tools-regex-from-examples-3901c8c0 -d '<json body>'
```

Example prompt: Generate a JavaScript regex from these examples that must match: 'user@example.com', 'hello+tag@mail.co.uk', 'name.last@sub.domain.org' — and must NOT match: 'notanemail', '@nodomain.com', 'missing@'.

## When to prefer this

Use this endpoint when you need to programmatically infer a regex from concrete string examples rather than writing one by hand, especially when the pattern logic is non-obvious or you want automatic validation. Ideal for agents building dynamic input validators, data pipelines, or form field matchers at runtime. Choose the flavor parameter to match your runtime (js for browsers/Node, python for Python scripts, pcre for PHP/Nginx/grep).

## Known failure modes

- No valid regex can satisfy both positive and negative examples simultaneously — returns error or partial match
- Too few examples provided to infer a meaningful pattern — may return overly broad or literal regex
- Contradictory examples (a string in both match and should_not_match) — validation failures reported
- Unsupported regex flavor requested — returns 400 or defaults
- Payment not settled via x402 — 402 Payment Required response blocks the call

## How this service works

Pay-per-call utility APIs for AI agents, settled in USDC via the x402 protocol.

## Output

Returns a JSON object containing the inferred regex pattern string, any flags needed, a human-readable explanation of what the pattern matches, and a validation report showing whether all positive examples matched and all negative examples were rejected, plus any failures.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "flavor": {
   "enum": [
    "js",
    "pcre",
    "python"
   ],
   "type": "string",
   "default": "js"
  },
  "examples": {
   "type": "array",
   "items": {
    "type": "string"
   },
   "maxItems": 50,
   "minItems": 1,
   "description": "Strings the regex MUST match"
  },
  "should_not_match": {
   "type": "array",
   "items": {
    "type": "string"
   },
   "maxItems": 50,
   "description": "Strings the regex MUST NOT match (optional)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "flags": "",
  "pattern": "^[\\w.+-]+@[\\w-]+(?:\\.[\\w-]+)+$",
  "validation": {
   "failures": [],
   "matchesAll": true,
   "rejectsAll": true
  },
  "explanation": "Matches simple email addresses."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-tools-regex-from-examples-3901c8c0/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.nichospt.net](https://www.zero.xyz/host/x402.nichospt.net/llms.txt)
