Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
PHP Regex - Advanced Password. - PHP Code Bank
PHP Regex - Advanced Password.
This script checks if $password is between 7 and 30 characters that contains at least one uppercase character, one lowercase character and one digit.
<?php
if( strlen($password)>6 ## If the password has more than 7 characters.
&& strlen($password)<31 ## Has less than 30 characters.
&& preg_match('`[A-Z]`',$password) ## Has at least one uppercase character.
&& preg_match('`[a-z]`',$password) ## Has at least one lowercase character.
&& preg_match('`[0-9]`',$password) ## Has at least one digit.
)
{
echo "Valid Password!";
}
else
{
echo "Invalid Password!";
}
?>
Comments
ghost 15 years ago
More then 7, less then 30 can be replaced with ([a-zA-Z0-9]+){7,30} instead though.
ghost 15 years ago
root, that would only check to see if any alphanumeric character existed, not that they each existed at least once. The conditional, though long, is fine with me… does what it's supposed to. The part that's not fine with me is the fact that you submitted 5 Code Bank submissions with just a regex each in them. Combine them into one submission and re-submit; there's no need to have 5 separate ones.