Discover Card Number Regex for JavaScript
/^(?: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 JavaScript. 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 JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.
Javascript Implementation
// Discover Card Number
// ReDoS-safe | RegexVault — Finance > Card Numbers
const discoverCardNumberRegex = /^(?: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 validateDiscoverCardNumber(input: string): boolean {
return discoverCardNumberRegex.test(input);
}
// Example
console.log(validateDiscoverCardNumber("6011111111111117")); // trueTest 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 JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. 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