php 正则表达式 匹配中文开头的字符串

utf-8编码
2024年11月01日 19:14
有1个网友回答
网友(1):

    function test($str){
if (preg_match("/^[\x81-\xfe][\x40-\xfe]?/",$str)) {
return "首字母有中文";
}
return "首字母没中文";
}
echo test("中1231213");//首字母有中文
echo test("123中");//首字母没中文