$username ="你好"; $pattern = '/^[x{4e00}-x{9fa5}]{2,20}$/u'; $res = preg_match($pattern,$username); var_dump($res);