I want a regex that should only match if the string contains minimum 10 to 16 characters with atleast, a number, a string, an uppercase, a lowercase character and a special character.
I think this string should pass this regexp test but this is not working :
The String does not include the apostrpohes' or quotes.
String : 'asdf@A1234';
Regexp: /^(?=.*[0-9])(?=.*[!@#$%^&*])(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9!@#$%^&*]{10,16}$/;
Can someone kindly suggest what I am missing?
function testpwd(pwd) {
var re = /^(?=.*[0-9])(?=.*[!@#$%^&*])(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9!@#$%^&*]{10,16}$/;
console.log(" Test Result is " + re.test(pwd) )
return re.test(pwd);
}
Update Sorry for the red flag Guys. The code is working. The error was somewhere else :). I am rephrasing the question so that It can be of some use for future visitors.