if(preg_match((?=^.{8,}$)((?=.*d)|(?=.*W+))(?![. ])(?=.*[A-Z])(?=.*[a-z]).*$, $_POST['password']): echo 'matched'; else: echo 'not matched'; endif;