Regex Utilities

Get Time Pattern

Returns ready-to-use regex patterns for validating time formats. Access via MCP in Cursor or Windsurf, or REST at GET /v1/regex/pattern/time. Supports 12-hour (3:45 PM), 24-hour (15:45), and seconds variants. Each pattern includes proper boundary anchors and handles edge cases like leading zeros.

API Endpoint

GET /v1/regex/pattern/time

Code Examples

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

Validates 12-hour format (1:30 PM, 12:05 AM), 24-hour format (13:45, 09:15), and optional seconds (14:30:25). Handles leading zeros and proper AM/PM notation.

How do I use time validation patterns in MCP with Claude Code?

Call the tool to get the regex pattern, then use it directly in your validation logic. The returned pattern includes anchors (^ and $) for complete string matching.

Does the pattern validate actual time ranges like 25:70?

Yes, it enforces valid ranges: hours 00-23 (24-hour) or 1-12 (12-hour), minutes and seconds 00-59. Invalid times like 25:70 won't match.

Can I get different time format patterns for specific use cases?

The endpoint returns multiple pattern variants. Choose the one matching your format requirements: strict 24-hour, flexible 12-hour, or with optional seconds.

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

This provides battle-tested patterns that handle edge cases like midnight (12:00 AM), noon boundaries, and proper zero-padding validation that custom regex often miss.

Try Get Time Pattern Now

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

Get Free API Key