If I understand the question right, you are looking to match only one EXACT string and not if a sub-string?
/^123456$/
Simply anchor the beginning and the end of the string. You can choose more than one string with the | (or)..
/^123456$|^12345$/
or
/^bedroom$|^closet$/
Without the anchors, regex will match the first or any sub-string that matches in a string depending on your flags.
I would only use regex to match allowed characters. To verify a match, you can use logic.
$some_regex = '/^[a-zA-Z0-9\S]{8,20}$/'; // whatever (matches all chars)
$password = '123456';
$password2 = '123456w@';
if(preg_match($some_regex, $password) && preg_match($some_regex, $password2) && $password == $password2){
return true;
}
else{
return false;
}