My 5 are conditions
- Trying to write regex for accepting alphanumeric string.
- It cannot start with number.
- Cannot have
_
hence not using\w
. - Length should be exactly
25
characters. - First 5 should be alphabets and next 20 should be numeric.
here is my regex
var str = "Aasdfds133147852369852147";
var Exp = /^([A-Za-z]+[0-9]){25}$/; //This fails..ERROR
//var Exp = /^([A-Za-z0-9]){25}$/; This pass ..SUCCESS, but fails my second condition
if(!str.match(Exp)){
alert("ERROR");
}
else {
alert("SUCCESS");
}
Help me tune my code..