# Aayat AI Regex Explainer

> Aayat AI Regex Explainer is a paid API for AI agents from aayatai.com, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-02).

Validates a JavaScript regular expression, explains each token in plain English, flags ReDoS risk, and tests it against up to 20 strings returning match groups.

## Facts

- Endpoint: POST https://aayatai.com/regex/explain?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-02
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/aayat-ai-regex-explainer-ba1e21bf
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_hX7tvXyBicydU2PC-c21c

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 aayat-ai-regex-explainer-ba1e21bf -d '<json body>'
```

Example prompt: Can you validate this regex and explain what each part does — `^(\d{3})-(\d{4})$` with no flags — then test it against '555-1234', '5551234', and 'abc-1234', and let me know if there's any ReDoS risk?

## When to prefer this

Choose this endpoint when you need not just pass/fail regex validation but also human-readable token-by-token explanation, security analysis for ReDoS vulnerabilities, and batch testing against multiple sample strings — all in a single call. It is purpose-built for JavaScript regex flavor, so prefer it over generic validators when the runtime target is Node.js or browser JavaScript.

## Known failure modes

- Invalid regex syntax returns valid:false with an error message describing the parse failure
- Pattern exceeding 500 characters is rejected
- More than 20 test strings causes request rejection
- Malformed JSON body returns 400 error
- Payment not provided results in 402 Payment Required response

## How this service works

Validate and explain a regular expression (JavaScript flavour): is it valid, what each part means in plain English, whether it risks catastrophic backtracking (ReDoS), and what it matches in up to 20 test strings (with groups). POST {pattern, flags, tests}.

## Output

A JSON object containing: whether the pattern is valid, an array of token objects each with a token string and plain-English meaning, a risk field indicating ReDoS danger (null if safe), the number of capturing groups, and a tests array showing for each input string whether it matched, plus all match objects with index, full match text, named groups, and positional capture groups.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "flags": {
   "type": "string",
   "maxLength": 8,
   "description": "JavaScript flags: g i m s u y d v."
  },
  "tests": {
   "type": "array",
   "items": {
    "type": "string",
    "maxLength": 500
   },
   "maxItems": 20,
   "description": "Strings to try it on."
  },
  "pattern": {
   "type": "string",
   "maxLength": 500,
   "minLength": 1,
   "description": "The regex source, without slashes, e.g. ^(\\d{3})-(\\d{4})$"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "risk": null,
  "error": null,
  "flags": "",
  "parts": [
   {
    "token": "^",
    "meaning": "start of the text (or line with the m flag)"
   },
   {
    "token": "(",
    "meaning": "start of capturing group"
   },
   {
    "token": "\\d",
    "meaning": "a digit (0-9)"
   },
   {
    "token": "{3}",
    "meaning": "repeat the previous item exactly 3 times"
   }
  ],
  "tests": [
   {
    "input": "555-1234",
    "matched": true,
    "matches": [
     {
      "index": 0,
      "match": "555-1234",
      "named": null,
      "groups": [
       "555",
       "1234"
      ]
     }
    ]
   },
   {
    "input": "5551234",
    "matched": false,
    "matches": []
   }
  ],
  "valid": true,
  "groups": 2,
  "pattern": "^(\\d{3})-(\\d{4})$"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/aayat-ai-regex-explainer-ba1e21bf/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from aayatai.com](https://www.zero.xyz/host/aayatai.com/llms.txt)
