# Regex Replace

> Regex Replace is a paid API for AI agents from x402.agentindex.world, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-16).

Replaces regular expression pattern matches in a given text string, with an optional maximum replacement count.

## Facts

- Endpoint: GET https://x402.agentindex.world/regex/replace?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-16
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/regex-replace-ba4c3c9d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_dUuxhOvrR1w5_Wb-_ilvg

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-replace-ba4c3c9d
```

Example prompt: In this log snippet, replace every occurrence of the pattern \d{3}-\d{2}-\d{4} with [REDACTED], and limit it to the first 3 replacements: 'John: 123-45-6789, Jane: 987-65-4321, Bob: 555-12-3456, Alice: 444-33-2222'.

## When to prefer this

Use this endpoint when you need a quick, pay-per-call regex find-and-replace on text without setting up a server-side script or runtime environment. Ideal for agents that need lightweight, stateless string transformation — especially when the pattern is dynamic and cannot be hardcoded. Prefer this over general-purpose LLM text editing when you need deterministic, pattern-exact substitution behavior.

## Known failure modes

- Invalid regex pattern causes a parse/compile error response
- Text or pattern fields missing results in a validation error
- Extremely long text or complex patterns may time out
- Malformed JSON input returns a 400 bad request
- count parameter of 0 is treated as unlimited replacements (default behavior)

## How this service works

Replace regular expression matches in text, with an optional max-replacement count.

## Output

Returns the input text with all (or up to count) regex pattern matches replaced by the specified replacement string. The result is the modified text string after substitution.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "text": {
   "type": "string",
   "title": "Text"
  },
  "count": {
   "type": "integer",
   "title": "Count",
   "default": 0
  },
  "pattern": {
   "type": "string",
   "title": "Pattern"
  },
  "replacement": {
   "type": "string",
   "title": "Replacement"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "result": "too many spaces",
  "replacements": 2
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/regex-replace-ba4c3c9d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.agentindex.world](https://www.zero.xyz/host/x402.agentindex.world/llms.txt)
