好吧,我正在为我们的密码策略编写一个密码检查器,它需要4个主要分类中的3个。我遇到问题的地方是特殊字符匹配。Preg_match所有特殊字符,密码检查
这里是我迄今:
private function PasswordRequirements($ComplexityCount) {
$Count = 0;
if(preg_match("/\d/", $this->PostedData['password']) > 0) {
$Count++;
}
if(preg_match("/[A-Z]/", $this->PostedData['password']) > 0) {
$Count++;
}
if(preg_match("/[a-z]/", $this->PostedData['password']) > 0) {
$Count++;
}
// This is where I need help
if(preg_match("/[~`[email protected]#$%^&*()_-+=\[\]{}\|\\:;\"\'<,>.]/", $this->PostedData['password']) > 0) {
$Count++;
}
if($Count >= $ComplexityCount) {
return true;
} else {
return false;
}
}
所以基本上我在做什么是检查每个字母,数字,大写字母,小写字母和特殊字符的字符串。我们对任何特殊字符没有任何限制,我也需要unicode字符。 \ W在这种情况下工作还是会再次包含数字?我在\ W上找不到很棒的文档,所以我不清楚这一部分。
有谁知道一个简单的正则表达式,可以涵盖所有不包含数字和字母的特殊字符和unicode字符吗?
任何人都可以自由使用这个,因为我认为超过一些人一直在寻找这个。
这是一个很好的网页,可以解释您的一些猜测:http://www.regular-expressions.info/reference.html – Marcus