I really don’t know regexp yet, but sooner or later I will read and learn.
But for now I need a regular expression matching a 3 or 4 digit cvv of a credit card so I can validate the input in javascript and later in PHP.
cvv are supposed to be 3 or 4 digit as far as I know.
I tried this in my javascript code and I am not sure if it is correct.
if (/[0-9]{3}+/.test(value))
return false;
To match 3 or 4 digits, use the following regular expression:
Explanation:
^: Start of string anchor[0-9]: Digit between 0 and 9 (you could also use\dhere){3,4}: A quantifier meaning between 3 and 4.$: End of string anchor