Enforcing Password Requirements
问题 I want to check if the user has successfully met the following requirements: The password has at least 8 characters Consists of one capital & one lowercase letter How would I do this? I am using the PHP script below: if ( strlen( $password ) < 8 ) { false } else { if ( preg_match( "/[^0,9]/", $password ) ) { // how to check the upper case and lower case } } 回答1: You can do that with a regex: if (!preg_match('/^(?=[a-z])(?=[A-Z])[a-zA-Z]{8,}$/', $password)) { //error } 回答2: Use preg_match("/[A