最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
判断字符串是否为中文
时间:2011-09-16 编辑:简简单单 来源:一聚教程网
下面简单的介绍了php教程和asp教程.net来判断字符串是否含有中文的代码。
$str = "中文";
if (preg_match("/[x7f-xff]/", $str)) {
echo "含有中文";
}else{
echo "没有中文";
}
或
$pattern = '/[^x00-x80]/';
if(preg_match($pattern,$str)){
echo "含有中文";
}else{
echo "没有中文";
}
/// 检测是否有中文字符
///
/// 输入字符串
///是否有中文字符
public static bool IsIncludeChinese(string inputData)
{
Regex regex = new Regex("[u4e00-u9fa5]");
Match m = regex.Match(inputData);
return m.Success;
}
相关文章
- 判断一个字符串里面包含有中文或者英文 01-19
- 看到有人问如何取中文为2的指定字符串字节数,研究一下: 01-18
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18