手机号的正则::$pattern='/^1(?:3[0-9]|5[012356789]|8[0256789]|7[0678])(\-?)\d{4}\1\d{4}$/';
手机号 正则的匹配判断
if(preg_match($pattern,$tel)){ echo "手机号正确"; }
//移动号段:::$cmcc = array(134,135,136,137,138,139,147,150,151,152,157,158,159,178,182,183,184,187,188);
//联通号段:::$cucc = array(130,131,132,145,155,156,171,175,176,185,186);
//电信号段:::$ctcc = array(133,149,153,173,177,180,181,189);
邮箱的正则:::$pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
邮箱 正则的匹配判断 if(preg_match($pattern,$email)){ echo "邮箱正确"; }
正则匹配中文汉字根据页面编码不同而略有区别:
GBK/GB2312编码:[x80-xff]+ 或 [xa1-xff]+
UTF-8编码:[x{4e00}-x{9fa5}]+/u