怎样检测中文
I我IS是Chinese中国人 --------------------编程问答-------------------- 你的问题是? --------------------编程问答--------------------@"^[\u4e00-\u9fa5]+$"--------------------编程问答-------------------- string ptn = "[\u4e00-\u9fa5]+|[a-zA-Z\\s]+";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(ptn);
string z = "I我IS是Chinese中国人";
foreach (Match m in reg.Matches(z))
{
Console.WriteLine(m.Value);
}
你要的不 --------------------编程问答--------------------
string str="I我IS是Chinese中国人";
public static string GetChina(string text)
{
string newStr = "";
foreach (char c in text.ToCharArray())
{
if (Regex.IsMatch(c.ToString(), @"^[\u4e00-\u9fa5]+$") == true)
{
newStr = newStr + c.ToString();
}
}
return newStr;
}
MessageBox.Show(GetChina(str));--------------------编程问答-------------------- string str="";
if (Regex.IsMatch(str, @"^[\u4e00-\u9fa5](\s*[\u4e00-\u9fa5])*$"))
{
}
else
{
}
--------------------编程问答-------------------- 下载微软件的动态库。可以简繁转换。和测试中英文。功能强大。比较不错。网上搜一下很多。
补充:.NET技术 , C#