0

I'm having really hard time to get a regular expression for the following cards / scenarios:

Maestro:

Valid:
5759877498192
67309415708416
6641120953323
633047943612610
50367590462448
509705198158

Not valid:
6369634818975813
66103205252298716302
6526725494191975280
67098365838600780
630453133428820927

regex: ^(6|50|56|57|58|503)(?!36)\d{11,18}$

Discover Card:

Valid:
6222117726251007070
6532550590530780378
6473780297817696280
6221567796889380121
6585471921818715
6223510391605033

Not valid:
62268883925361333717
64795258022225006
6004952515759546352

regex: ^6(011|5|22(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[01][0-9]|92[0-5])|4[4-9])[0-9]+$

As you can see the reg exp I'm using fails in some scenarios.

I'm using the following url as reference https://en.wikipedia.org/wiki/Payment_card_number

user2019037
  • 764
  • 1
  • 7
  • 14

0 Answers0