Form Validation Fails even when criteria is met

Hello.

I have found an old post from about 8 years ago with the code below which should do what i need but no matter what is entered into the form the validation fails.

i have a simple form where on submit im using this code or some other code if someone knows how to do this, to validate the text entered into the password field.

I require the inputted text to be more than 8 characters in length, contain a lowercase letter, contain a uppercase letter, contain a number and also contain any symbol.

The code i found to do this is below but this just fails everytime!

$pwd={pswd} ;
if (preg_match("#.^(?=.{8,20})(?=.[a-z])(?=.[A-Z])(?=.[0-9]).*$#", $pwd)){
return true ;
} else {
sc_error_message(“Your new password must comply with password requirements”) ;
}