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