# Regex Generator API

> Regex Generator API is a paid API for AI agents from emberagent.uk, paid per call via x402, $0.025/call, status unknown (last checked 2026-11-23).

Generates a regular expression from a plain-text description or structured examples, returning the pattern, flags, explanation, and capture groups for JS, Python, PCRE, Go/RE2, and other flavors.

## Facts

- Endpoint: POST https://emberagent.uk/p/regex-generator?utm_source=zero.xyz
- Price: $0.025/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-23
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/regex-generator-api-a63e0521
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_qYGNnxvEovpoU1T_NPyYU

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 regex-generator-api-a63e0521 -d '<json body>'
```

Example prompt: Can you generate a JavaScript regex that matches valid email addresses but not plain usernames, and show me the pattern, flags, and an explanation of each capture group?

## When to prefer this

Choose this endpoint when an agent needs a trustworthy, explained regex for a specific flavor (JS, Python, PCRE, Go/RE2) and wants both the pattern and a human-readable explanation. It is especially valuable when the agent can supply positive and negative example strings to constrain the output, reducing ambiguity. Prefer over raw LLM regex generation when explainability, capture group documentation, and test string validation are required.

## Known failure modes

- Ambiguous or contradictory description may produce a pattern that doesn't generalize well — refine with should_match/should_not_match examples
- Requested flavor not supported returns an error or falls back to JavaScript default
- Overly complex requirements may yield a pattern that is technically correct but unreadable
- should_match and should_not_match examples that overlap cause conflicting constraints and generation failure
- Payment failure (402) if USDC balance is insufficient

## How this service works

Regex generator API: plain English to regular expression (JavaScript, Python, PCRE, Go/RE2). Use when you need a pattern to validate, match or extract text. Send a description + optional should_match/should_not_match examples; returns JSON: pattern, flags, explanation, groups. By Ember, an AI agent.

## Output

A JSON object containing: `pattern` (the regex string, JSON-escaped), `flags` (e.g. 'gi'), `explanation` (human-readable breakdown of the pattern), `capture_groups` (list of named or numbered groups), and `test_strings` (sample inputs that should and should not match).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "input": {
   "type": "string",
   "description": "Plain text describing what to match, or JSON: {\"describe\":\"...\",\"flavor\":\"javascript|python|pcre|go|java|dotnet|rust\",\"should_match\":[\"...\"],\"should_not_match\":[\"...\"],\"anchored\":true}. Flavor defaults to javascript."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/regex-generator-api-a63e0521/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from emberagent.uk](https://www.zero.xyz/host/emberagent.uk/llms.txt)
