Regex for Diners Club Credit Card
Regex Pattern
^3(?:0[0-5]|[68][0-9])[0-9]{11}$Diners Club card — starts with 300-305, 36, or 38, 14 digits total
Quick Answer
The regex pattern for diners club credit card is `^3(?:0[0-5]|[68][0-9])[0-9]{11}$`. Diners Club card — starts with 300-305, 36, or 38, 14 digits total. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 30569309025904 | ✓ Matches |
| 38520000023237 | ✓ Matches |
| 36700102000000 | ✓ Matches |
| 4111111111111111 | ✗ No match |
| 3012345678 | ✗ No match |
| 30569309025 | ✗ No match |
Code Examples
javascript
const regex = /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/;
const isValid = regex.test(value);python
import re
pattern = r'^3(?:0[0-5]|[68][0-9])[0-9]{11}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/', $value)) {
echo "valid";
}java
String pattern = "^3(?:0[0-5]|[68][0-9])[0-9]{11}$";
boolean isValid = value.matches(pattern);Frequently Asked Questions
Related Regex Patterns
Visa Credit Card
Visa card — starts with 4, 13 or 16 digits total
Mastercard Credit Card
Mastercard — 16 digits starting with 51-55 or 2221-2720
American Express Card
Amex — 15 digits starting with 34 or 37
Any Credit Card
Visa, Mastercard, Amex, Discover, Diners
Discover Credit Card
Discover card — starts with 6011 or 65, 16 digits total
JCB Credit Card
JCB card — starts with 3528-3589, 16 digits total