# 402utils Regex Test & ReDoS Guard

> 402utils Regex Test & ReDoS Guard is a paid API for AI agents from 402utils.com, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-10).

Tests a regex pattern against one or more input strings using match, matchAll, or replace modes, with a mandatory static ReDoS safety check that rejects catastrophic patterns before execution.

## Facts

- Endpoint: POST https://402utils.com/v1/regex-test?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-10
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/402utils-regex-test-redos-guard-81e05bd2
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_GOxHz93-VOwrbM1lFRD5t

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 402utils-regex-test-redos-guard-81e05bd2 -d '<json body>'
```

Example prompt: Test my regex pattern `^(\d{3})-?(\d{3})-?(\d{4})$` with the flag `i` in matchAll mode against these three strings: '555-867-5309', 'not-a-phone', and '8005551234' — and make sure it's safe to run first.

## When to prefer this

Choose this endpoint when an AI agent is generating or dry-running regex patterns and needs a safe execution environment — particularly when the patterns are untrusted or LLM-generated and could be catastrophically backtracking. Also ideal when you need to test a single pattern against up to 50 strings in one call, or when you need replace mode with capture group substitutions. Prefer this over running regex locally when ReDoS safety guarantees are required on a serverless/Workers runtime where timeouts cannot stop runaway patterns.

## Known failure modes

- Pattern flagged as ReDoS-unsafe — rejected before execution with a descriptive safety error
- Pattern syntax error — invalid regex returns a parse error
- Input string exceeds 10,000 character limit — returns a validation error
- inputs array exceeds 50 items — returns a validation error
- mode set to 'replace' without providing a replacement string — returns a missing-field error
- Unsupported flags passed — returns a validation error

## How this service works

Test a regex against one or many inputs, safely. Send {pattern, flags?, input|inputs[], mode?}: 'match' returns the first match + capture groups, 'matchAll' every match, 'replace' the rewritten string (needs {replacement}). A mandatory ReDoS guard statically rejects catastrophic patterns (nested quantifiers, `.*.*$`, backrefs) BEFORE running — on Workers no timeout can stop a runaway regex. For agents that generate and dry-run regexes.

## Output

Returns the match result according to the chosen mode: for 'match', the first match and any named or indexed capture groups; for 'matchAll', every match found across the input; for 'replace', the fully rewritten string with substitutions applied. If the pattern is detected as catastrophically backtracking (e.g. nested quantifiers, `.*.*$`, or backreferences), the request is rejected with a ReDoS safety error before any execution occurs.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "mode": {
   "enum": [
    "match",
    "matchAll",
    "replace"
   ],
   "type": "string",
   "default": "match",
   "description": "match | matchAll | replace."
  },
  "flags": {
   "type": "string",
   "description": "Any of gimsuyd (g added automatically for matchAll)."
  },
  "input": {
   "type": "string",
   "description": "A single input string (≤ 10000 chars)."
  },
  "inputs": {
   "type": "array",
   "items": {
    "type": "string"
   },
   "maxItems": 50,
   "description": "Multiple input strings."
  },
  "pattern": {
   "type": "string",
   "description": "The regular expression source (no delimiters)."
  },
  "replacement": {
   "type": "string",
   "description": "Replacement string (with $1, $<name>) — required for mode 'replace'."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/402utils-regex-test-redos-guard-81e05bd2/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from 402utils.com](https://www.zero.xyz/host/402utils.com/llms.txt)
