Regex Utilities

Escape Pattern

Escapes special regex characters in text strings to prevent pattern matching errors. Access via MCP in Cursor/Windsurf or REST at `/v1/regex/escape`. Input "[email protected]" outputs "user@domain\.com" with backslashes added. Essential for sanitizing user input before regex operations in AI agents.

API Endpoint

GET /v1/regex/escape

Code Examples

curl "https://tinyfn.io/v1/regex/escape" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/regex/escape', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/regex/escape',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's regex tools:

{
  "mcpServers": {
    "tinyfn-regex": {
      "url": "https://tinyfn.io/mcp/regex",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

What regex characters does this tool escape?

Escapes all special regex metacharacters: . ^ $ * + ? { } [ ] \ | ( ). These become literal characters when escaped with backslashes.

How do I use regex escape in MCP with Claude Code?

Call the escape_pattern tool with your text string. It returns the escaped version ready for safe regex compilation without pattern interpretation errors.

When should I escape regex patterns vs user input?

Escape user input when you want literal matching, not pattern matching. Don't escape actual regex patterns you intend to use for matching.

Does this handle Unicode characters correctly?

Yes, it preserves Unicode characters while only escaping ASCII regex metacharacters. Non-ASCII characters pass through unchanged.

What's the difference between this and manual escaping?

This ensures complete coverage of all regex metacharacters and handles edge cases. Manual escaping often misses characters like parentheses or brackets.

Try Escape Pattern Now

Get your free API key and start using Escape Pattern in seconds.

Get Free API Key