function strLength($string){
$array = preg_split('/(?<!^)(?!$)/u',$string);
return count($array);
}
固话
$result = preg_match("/^(0(10|21|22|23|[1-9][0-9]{2})(-|))?[0-9]{7,8}$/", $phone,$match);
移动电话
$result = preg_match("/^((\(\d{3}\))|(\d{3}\-))?1\d{10}$/", $phone,$match);
邮箱
strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-]+(\.\w+)+$/", $email)
URL地址
preg_match("/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"])*$/", $str);
PHP求字符串的长度 部分正则表达式
最新推荐文章于 2021-04-04 18:11:13 发布