DD
DevDash

Regex for Discover Credit Card

Regex Pattern

^6(?:011|5[0-9]{2})[0-9]{12}$

Discover card — starts with 6011 or 65, 16 digits total

Quick Answer

The regex pattern for discover credit card is `^6(?:011|5[0-9]{2})[0-9]{12}$`. Discover card — starts with 6011 or 65, 16 digits total. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.

Test Examples

InputResult
6011111111111117✓ Matches
6500000000000002✓ Matches
6011000990139424✓ Matches
4111111111111111✗ No match
6010111111111117✗ No match
601111111111✗ No match

Code Examples

javascript

const regex = /^6(?:011|5[0-9]{2})[0-9]{12}$/;
const isValid = regex.test(value);

python

import re
pattern = r'^6(?:011|5[0-9]{2})[0-9]{12}$'
if re.match(pattern, value):
    print("valid")

ruby

pattern = /^6(?:011|5[0-9]{2})[0-9]{12}$/
if value =~ pattern
  puts "valid"
end

php

if (preg_match('/^6(?:011|5[0-9]{2})[0-9]{12}$/', $value)) {
    echo "valid";
}

java

String pattern = "^6(?:011|5[0-9]{2})[0-9]{12}$";
boolean isValid = value.matches(pattern);

Frequently Asked Questions

Related Regex Patterns

Want API access + no ads? Pro coming soon.