php常用正则表达式

//手机号正则
‘preg_phone’ => ‘/^((13[0-9])|147|(15[0-35-9])|180|181|182|(18[5-9]))[0-9]{8}$/’,

//验证手机号是否注册过
if(!preg_match(C(‘preg_phone’),$info[‘phone’])){
$this->error(‘手机号格式不正确’);
}

//身份证正则
‘indentity_card15’ => ‘/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/’,
‘indentity_card18’ => ‘/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/’,

//验证身份证信息
if(count($_POST[‘indentity_card’]) == 15){ //15位身份证
$preg_match = preg_match(C(‘indentity_card15’),$_POST[‘indentity_card’]);
}else{ //18位身份证
$preg_match = preg_match(C(‘indentity_card18’),$_POST[‘indentity_card’]);
}
if(!$preg_match){
$this->error(“请输入正确的身份证号码”);
}