DEV Community

2x lazymac
2x lazymac

Posted on • Originally published at api.lazy-mac.com

How to Use the Regex Toolkit API — Free REST + MCP Server

Regex is powerful but hard to debug. This API lets you test patterns, get human-readable explanations, find common patterns, replace text, benchmark performance, and escape special characters — all via REST.

Try It Right Now

curl -s -X POST https://api.lazy-mac.com/regex/api/v1/test \
  -H "Content-Type: application/json" \
  -d '{"pattern": "\\d+", "text": "I have 42 apples and 7 oranges"}' | jq
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "pattern": "\\d+",
  "text": "I have 42 apples and 7 oranges",
  "matchCount": 2,
  "matches": [
    { "match": "42", "index": 7, "length": 2 },
    { "match": "7", "index": 21, "length": 1 }
  ]
}
Enter fullscreen mode Exit fullscreen mode

All Endpoints

Endpoint Description
POST /api/v1/test Test a pattern against text
POST /api/v1/replace Find and replace with regex
POST /api/v1/split Split text by pattern
POST /api/v1/validate Check if pattern is valid
GET /api/v1/patterns 17 common pre-built patterns
GET /api/v1/patterns/:name Get specific pattern (email, url, phone...)
POST /api/v1/explain Human-readable regex explanation
POST /api/v1/escape Escape special characters
POST /api/v1/benchmark Performance benchmark

Browse Pre-Built Patterns

curl -s https://api.lazy-mac.com/regex/api/v1/patterns | jq '.patterns[:3]'
Enter fullscreen mode Exit fullscreen mode
[
  { "name": "email", "description": "Matches standard email addresses" },
  { "name": "url", "description": "Matches HTTP and HTTPS URLs" },
  { "name": "phone", "description": "Matches US/international phone numbers" }
]
Enter fullscreen mode Exit fullscreen mode

17 patterns included: email, url, phone, ipv4, ipv6, date, uuid, hex color, credit card, SSN, and more.

Explain a Regex

curl -s -X POST https://api.lazy-mac.com/regex/api/v1/explain \
  -H "Content-Type: application/json" \
  -d '{"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}' | jq
Enter fullscreen mode Exit fullscreen mode

Use as an MCP Server

{
  "mcpServers": {
    "regex": {
      "url": "https://api.lazy-mac.com/regex/mcp"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Ask Claude: "Test this regex pattern against my sample text" or "Explain what this regex does"

Pricing

Tier Requests/mo Price
Free 100 $0
Pro 10,000 $9/mo
Business Unlimited $49/mo

Get Pro Access on Gumroad →


Browse all 22 APIs at api.lazy-mac.com →

More from the lazymac API Toolkit:

Top comments (0)