Discover Card Number Regex for PHP
/^(?:6011[0-9]{12}|64[4-9][0-9]{13}|65[0-9]{14}|622(?:1(?:2[6-9]|[3-9][0-9])|[2-8][0-9]{2}|9(?:[01][0-9]|2[0-5]))[0-9]{10})$/What this pattern does
This page provides a comprehensive, battle-tested regular expression for matching discover card number, ported and verified for PHP. Financial data validation has zero tolerance for false negatives — a missed invalid entry can corrupt downstream calculations. The snippet below is ready to drop into your PHP project — whether you're validating in a Laravel validator, a WordPress plugin, or a standalone PHP script.
Php Implementation
<?php
// Discover Card Number
// ReDoS-safe | RegexVault — Finance > Card Numbers
define('DISCOVER_CARD_NUMBER_PATTERN', '/^(?:6011[0-9]{12}|64[4-9][0-9]{13}|65[0-9]{14}|622(?:1(?:2[6-9]|[3-9][0-9])|[2-8][0-9]{2}|9(?:[01][0-9]|2[0-5]))[0-9]{10})$/');
function validate_discover_card_number(string $input): bool {
return (bool) preg_match(DISCOVER_CARD_NUMBER_PATTERN, $input);
}
// Example
var_dump(validate_discover_card_number("6011111111111117")); // bool(true)Test Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
6011111111111117 | 4111111111111111 |
6500000000000002 | 5500005555555559 |
6441111111111111 | 6010111111111117 |
6221261111111118 | 60111111111111170 |
When to use this pattern
This pattern is drawn from the Finance > Card Numbers category and carries a ReDoS-safe certification. That matters for PHP developers because especially relevant in PHP where PCRE backtracking limits can trigger silent failures on malicious input. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.
Common Pitfalls
Discover cards are accepted on the UnionPay network in China and vice versa. The 622xxx range overlaps with UnionPay BINs — context determines which network to route to.
Technical Notes
Discover has multiple BIN ranges. The 622126-622925 range (UnionPay cobranded) was added later. Some validators miss the 644-649 and UnionPay ranges.
Have a pattern that belongs in the vault?
Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.
Submit a Pattern