Regex Utilities

Get Slug Pattern

Returns a regex pattern for validating URL slugs — lowercase letters, numbers, and hyphens only. Access via MCP in Cursor or Windsurf, or call GET /v1/regex/pattern/slug directly. Perfect for validating blog post URLs, product identifiers, or API endpoints. The pattern enforces web-safe characters and prevents consecutive hyphens.

API Endpoint

GET /v1/regex/pattern/slug

Code Examples

curl "https://tinyfn.io/v1/regex/pattern/slug" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/regex/pattern/slug', {
  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/slug',
    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 pattern does this return for URL slug validation?

Returns a pattern like ^[a-z0-9]+(?:-[a-z0-9]+)*$ that matches lowercase alphanumeric characters with single hyphens as separators, no leading/trailing hyphens.

How do I use the slug pattern in my MCP-enabled editor?

Call the tool through Claude or Cursor to get the regex, then use it in your validation logic. The deterministic pattern ensures consistent slug validation across your application.

Does the slug pattern allow uppercase letters or underscores?

No, it only allows lowercase letters (a-z), numbers (0-9), and single hyphens as separators. This follows standard URL slug conventions for SEO and readability.

Can I use this pattern to validate existing slugs in my database?

Yes, the returned regex works perfectly for batch validation. Run it against your existing slugs to find any that don't meet standard URL slug requirements.

What's the difference between this and writing my own slug regex?

This provides a battle-tested, standards-compliant pattern that handles edge cases like preventing consecutive hyphens and ensuring proper start/end boundaries.

Try Get Slug Pattern Now

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

Get Free API Key