Any Credit Card Number
intermediateMatches major credit card numbers (Visa, Mastercard, Amex, Discover).
credit-cardpaymentvalidationmulti-brand
Pattern
/(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{1,4}/gTry It
0 of 7 strings matched
Explanation
Matches Visa (4), Mastercard (51-55), Amex (34/37), and Discover (6011/65) card numbers with optional space or hyphen separators.
Test Strings
Matching
- 4111111111111111
- 5500000000000004
- 371449635398431
- 6011111111111117
Non-matching
- 9999999999999999
- abc
- 12345
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{1,4}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);