# FastX402 Regex Escape

> FastX402 Regex Escape is a paid API for AI agents from fastx402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-18).

Escapes a literal text string for safe use in a regex pattern, returning both the escaped string and a ready-to-use anchored pattern for JavaScript, Python, or PCRE flavors.

## Facts

- Endpoint: GET https://fastx402.tools/regex-escape?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-18
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/fastx402-regex-escape-8e91b77a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_fi56FwrzddXmTI_wkEvne

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 fastx402-regex-escape-8e91b77a
```

Example prompt: Escape the text 'a.b*c+' so I can use it safely as a literal match in a JavaScript regex — give me the escaped string and the full pattern.

## When to prefer this

Use this endpoint when you need to safely embed arbitrary user-supplied or dynamic text inside a regex pattern without manually tracking which characters need escaping. It is especially useful when the target regex flavor matters (JavaScript vs Python vs PCRE), since escaping rules differ subtly. Prefer this over writing your own escaping logic when correctness and flavor-specificity are important.

## Known failure modes

- Missing required 'text' query parameter returns an error
- Text exceeding 2000 characters is rejected
- Invalid flavor value (anything other than javascript, python, or pcre) may return an error or default to javascript
- Payment failure via x402 protocol results in 402 response before processing

## How this service works

216 pay-per-call tools for AI agents, from $0.001 per request in USDC on Base or Solana with x402. No account, no API key.

## Output

A JSON object containing the original text, the regex flavor used, the escaped version of the string with all metacharacters properly backslashed, and a complete anchored regex pattern string (e.g. /^escaped_text$/ for JavaScript) ready to paste into code.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "text"
     ],
     "properties": {
      "text": {
       "type": "string",
       "description": "Literal text to escape (max 2000 characters)"
      },
      "flavor": {
       "type": "string",
       "description": "Target regex flavor: javascript (default), python, or pcre"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "text": {
       "type": "string"
      },
      "flavor": {
       "type": "string"
      },
      "escaped": {
       "type": "string"
      },
      "pattern": {
       "type": "string"
      }
     }
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "text": "a.b*c+",
  "flavor": "javascript",
  "escaped": "a\\.b\\*c\\+",
  "pattern": "/^a\\.b\\*c\\+$/"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/fastx402-regex-escape-8e91b77a/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from fastx402.tools](https://www.zero.xyz/host/fastx402.tools/llms.txt)
