Answer the question
In order to leave comments, you need to log in
Regular expression for MIR card number?
Hello. Help me write a regular expression, please.
I'm trying to determine if this is a map of the world by the first digits
if (num.match(/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[01]|2720)[0-9]{0,}$/)) {
return alert('MasterCard');
} else if (num.match(/^4[0-9]{0,}$/) || num.match(/^4\d{12}/)) {
return alert('Visa');
} else if (num.match(/^(5[06789]|6)[0-9]{0,}$/) || num.match(/^4\d{12}/)) {
return alert('Maestro');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question