REGEXVAULTv2.0
Finance/Card Numbers
Verified Safe

Discover Card Number Regex for Java

/^(?: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 Java. 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 Java project — whether you're validating in a Spring Boot controller, a Jakarta EE service, or a standalone utility class.

Java Implementation

Java
// Discover Card Number
// ReDoS-safe | RegexVault — Finance > Card Numbers

import java.util.regex.Pattern;

public class DiscoverCardNumberValidator {
    private static final Pattern PATTERN =
        Pattern.compile("^(?: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})$");

    public static boolean validate(String input) {
        return PATTERN.matcher(input).matches();
    }

    // Example
    public static void main(String[] args) {
        System.out.println(validate("6011111111111117")); // true
    }
}

Test Cases

Matches (Valid)
Rejects (Invalid)
60111111111111174111111111111111
65000000000000025500005555555559
64411111111111116010111111111117
622126111111111860111111111111170

When to use this pattern

This pattern is drawn from the Finance > Card Numbers category and carries a ReDoS-safe certification. That matters for Java developers because critical in Java applications since the JVM regex engine uses backtracking and is susceptible to ReDoS without careful pattern design. 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