Visa Card Number
beginnerMatches Visa credit card numbers (starts with 4, 13 or 16 digits).
credit-cardvisapaymentvalidation
Pattern
/4\d{3}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}/gTry It
0 of 6 strings matched
Explanation
Matches Visa card numbers starting with 4, with 16 total digits optionally separated by spaces or hyphens in groups of 4.
Test Strings
Matching
- 4111111111111111
- 4111 1111 1111 1111
- 4111-1111-1111-1111
Non-matching
- 5111111111111111
- 411111111111
- 4111-111-111-1111
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}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);