Possible Duplicate:
Use regular expressions to validate passwords
I'm trying to code a php part where I have to make sure password is:
- At least 6 characters long
- At least one uppercase letter
- At least one lowercase letter
- At Least one numeric character
- At least one non-alphanumeric character
I have to make sure that the password matches the "Re-Enter password" section. I have the validation for password and password retype, is this the best way to express that?
if ($pass != $repass)
{
$repassErrorMsg = "Your password does not match the password entered above";
}
I am not sure how I can validate password to the cases listed above. I know how to do RegEx to verify solid formats, but I am not sure how to validate the following case if format is flexible. How can I express my password RegEx to validate any of the case scenarios (ex. at least one numeric) for the password the the user chooses. He may have any of the case scenarios entered anywhere in the password textbox.