Mastercard Number
intermediateMatches Mastercard credit card numbers (starts with 51-55 or 2221-2720).
credit-cardmastercardpaymentvalidation
Pattern
/(?:5[1-5]\d{2}|2(?:2(?:2[1-9]|[3-9]\d)|[3-6]\d{2}|7(?:[01]\d|20)))[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}/gTry It
0 of 6 strings matched
Explanation
Matches Mastercard numbers in the 51-55 and 2221-2720 IIN ranges with 16 total digits, optionally separated by spaces or hyphens.
Test Strings
Matching
- 5111111111111118
- 5500 0000 0000 0004
- 2221-0012-3412-3456
Non-matching
- 4111111111111111
- 6011111111111117
- 5600000000000000
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:5[1-5]\d{2}|2(?:2(?:2[1-9]|[3-9]\d)|[3-6]\d{2}|7(?:[01]\d|20)))[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);