Credit Card Regex Pattern

Example:
^[0-9]{13,19}$ Matches: ✓ 4532123456789012 (Visa) ✓ 5425233430109903 (Mastercard)
Basic credit card validation: ^[0-9]{13,19}$. For production, use Luhn algorithm validation too.
Try Regex Lab →

FAQs

Should I use only regex for credit cards?

No! Always use Luhn algorithm (mod-10 checksum) for actual validation. Regex only checks format.