Regex Utilities

Get Credit Card Pattern

Returns production-ready regex patterns for validating major credit card types including Visa, Mastercard, American Express, and Discover. Access via MCP in Cursor or Windsurf for instant pattern generation, or call GET /v1/regex/pattern/credit-card directly. Outputs industry-standard patterns that catch format errors before payment processing, saving API calls and improving user experience.

API Endpoint

GET /v1/regex/pattern/credit-card

Code Examples

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

Covers all major card types: Visa (4xxx), Mastercard (5xxx), American Express (34xx/37xx), and Discover (6xxx). Each pattern validates both number length and starting digit requirements per industry standards.

How do I use this with MCP in my AI coding workflow?

In Cursor or Windsurf, ask your AI assistant to 'get credit card validation regex'. The MCP tool returns the pattern instantly, which you can then integrate into form validation or payment processing code.

Does the regex pattern validate Luhn checksum algorithm?

No, this returns format validation patterns only (length and starting digits). For Luhn algorithm validation, combine with TinyFn's credit card validation tool for complete verification.

Can I get patterns for specific card types only?

The endpoint returns comprehensive patterns for all major types. Filter client-side if you need specific card validation, or use the individual card type validation tools for targeted checks.

What's the difference between this and online regex generators?

TinyFn provides tested, production-ready patterns that follow current payment industry standards. No guesswork or outdated patterns that miss edge cases in real payment forms.

Try Get Credit Card Pattern Now

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

Get Free API Key