/**
* 邀请码规则检查
* @return boolean
*/
public static function check($code, &$ruleHit=''){
//连续3个相同字符
if(preg_match("/([0-9A-Z])\\1{2,}/u", $code, $match)){
$ruleHit = '有连续3个相同的字符,它是'.$match[1];
return false;
}
//连续3个递增字符
if(preg_match('/(123|234|345|456|567|678|789)/', $code, $match)){
$ruleHit = '有连续3个递增的字符,它是'.$match[1];
return false;
}
//连续3个递减字符
if(preg_match('/(321|432|543|654|765|876|987)/', $code, $match)){
$ruleHit = '有连续3个递增的字符,它是'.$match[1];
return false;
}
//AABB模式
if(preg_match('/(\d)\1(\d)\2/', $code, $match)){
$ruleHit = "aabb模式".$match[0];
return false;
}
//ABAB模式
if(preg_match('/(\d)(\d)\1\2/', $code, $match)){
$ruleHit = "abab模式".$match[0];
return false;
}
return true;
}
PHP 靓号匹配方法
最新推荐文章于 2021-07-09 11:30:53 发布