DD
DevDash

Regex for UnionPay Credit Card

Regex Pattern

^62[0-9]{14,17}$

UnionPay card — starts with 62, 16-19 digits total

Quick Answer

The regex pattern for unionpay credit card is `^62[0-9]{14,17}$`. UnionPay card — starts with 62, 16-19 digits total. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.

Test Examples

InputResult
6200000000000003✓ Matches
62123456789012345✓ Matches
621234567890123456✓ Matches
4111111111111111✗ No match
6100000000000003✗ No match
62123456789✗ No match

Code Examples

javascript

const regex = /^62[0-9]{14,17}$/;
const isValid = regex.test(value);

python

import re
pattern = r'^62[0-9]{14,17}$'
if re.match(pattern, value):
    print("valid")

ruby

pattern = /^62[0-9]{14,17}$/
if value =~ pattern
  puts "valid"
end

php

if (preg_match('/^62[0-9]{14,17}$/', $value)) {
    echo "valid";
}

java

String pattern = "^62[0-9]{14,17}$";
boolean isValid = value.matches(pattern);

Frequently Asked Questions

Related Regex Patterns

Want API access + no ads? Pro coming soon.