Regex Utilities

Get Phone Pattern

Returns regex patterns for phone number validation across different formats and countries. Access via MCP in Cursor/Windsurf or REST at `/v1/regex/pattern/phone`. Get patterns for US format `^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$`, international formats, or loose validation. Perfect for form validation in AI-assisted development workflows.

API Endpoint

GET /v1/regex/pattern/phone

Code Examples

curl "https://tinyfn.io/v1/regex/pattern/phone" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/regex/pattern/phone', {
  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/pattern/phone',
    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 phone number formats does the regex pattern support?

Supports US/NANP formats (with/without country code, various separators), international E.164 format, and configurable loose patterns for different regional formats.

How do I use phone regex patterns in MCP-enabled editors?

Call the MCP tool to get the pattern, then use it directly in your validation code. Works seamlessly in Cursor, Windsurf, and other MCP-compatible editors for instant form validation.

Can I get different strictness levels for phone validation?

Yes, the tool provides strict patterns for specific formats and loose patterns that accept common variations like spaces, dashes, parentheses, and optional country codes.

What's the difference between US and international phone patterns?

US patterns handle NANP format with area codes, while international patterns follow E.164 standard with country codes. Both include variations for common formatting.

Do the regex patterns handle edge cases like extensions?

Standard patterns focus on core phone numbers. For extensions and complex parsing, combine with additional validation or use the patterns as a first-pass filter.

Try Get Phone Pattern Now

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

Get Free API Key