Other Resources:

JCB credit card number validation

Q

All credit card numbers issued by JCB have 3 sets of numbers: JCB cards start with 2131 have 15 digits. JCB cards start with 1800 have 15 digits. JCB cards start with 35 have 16 digits. For example, 3566002020360505 is a valid Visa credit card number.

How to write a single regular expression to validate a JCB credit card number described above?

✍: FYIcenter.com

A

Here is the regular expression to validate a JCB credit card number:

```
^(?:2131|1800|35[0-9]{3})[0-9]{11}$
^ - begin of the string
(?:2131|1800|35[0-9]{3}) - non-capturing group of 3 possible parts
2131 - matches 2131
| - or operator
1800 - matches 1800
| - or operator
35[0-9]{3} - 5 digits start with 35
[0-9] - any decimal digit
{11} - repeating 12 times
$ - end of the string
```

2019-01-01, 0👍, 1💬

Popular Posts:

All credit card numbers issued by JCB have 3 sets of numbers: JCB cards start with 2131 have 15 digi...

How to write a regular expression to parse key-value entries from Windows .INI files? Here is an exa...

How to capture the Soso Spider entries from Web log file? Here are some Web log file entries: 127.0....

All credit card numbers issued by JCB have 3 sets of numbers: JCB cards start with 2131 have 15 digi...

How to write a regular expression to parse key-value entries from Windows .INI files? Here is an exa...