1

There are very detailed regex expressions to identify Visa, MasterCard, Discover and other popular credit card numbers.

However, there are tons of other credit cards; termed popularly as Store Credit Cards (these are not the Visa or Amex powered cards). Examples of these cards are Amazon, GAP brands, Williams Sonoma, Macy's and so on. Most of these are Synchrony Bank Credit Cards.

Is there a regex to identify these different brand credit card numbers?

Shreerang
  • 367
  • 4
  • 15
  • 1
    I won't close as duplicate, but there are many references on the web covering regex for the various credit card providers, [such as this one](https://www.regular-expressions.info/creditcard.html). Please do some research before posting a question to Stack Overflow. – Tim Biegeleisen Jan 31 '19 at 05:19
  • 1
    I was afraid I was going to see comments like these, but my question is neither a duplicate nor did I find any information when I googled it. And yes I have seen the article you have linked to. – Shreerang Jan 31 '19 at 05:43
  • OK, fair enough +1 I can see that you are asking about other cards. Maybe you could write to Amazon to ask about the pattern they are using. – Tim Biegeleisen Jan 31 '19 at 05:44
  • 1
    Thought of doing that. But that is just Amazon. There are tons of brands that work with Synchrony. I would post a link to that list but am on a phone right now. – Shreerang Jan 31 '19 at 05:45
  • 2
    If you give me the pattern of each of those, we can make some regex for you! – Allan Jan 31 '19 at 05:57
  • I don't have the patterns. If I did I would build some regex too – Shreerang Jan 31 '19 at 06:13

2 Answers2

1

It's ludicrous to use a regex to identify the network. All it takes is a prefix matching at most.

A card number has 16 digits. The first few identify the network and the bank.

Some people would say that Visa starts with 4 and MasterCard starts with 5 but that's a broad approximation at best. You can have a look at your card, should be right most of the time.

It would be easy to figure out what a card is if one could get a registry of known prefixes, but there is no public registry to my knowledge. I highly doubt that any of the parties involved would like to publish that information.

user5994461
  • 5,301
  • 1
  • 36
  • 57
1

The first eight digits (until recently this was six digits) of an international card number are known as the Issuer Identification Number (IIN) and the registry that maintains this index is the American Bankers Association

The list of IINs is updated monthly and spans tens of thousands of rows. Unfortunately a fixed Regex isn't going to be accurate for any length of time.

PaulG
  • 13,871
  • 9
  • 56
  • 78