正则表达式=》判断中文字
//Name Classification
string input = "Eng中";
string patternZh = @"^\(*([\u4E00-\u9FFF'_\s\.\,\-]{1,98})?\)*$";
Match match = Regex.Match(input, patternZh);
Console.WriteLine("測試:"+input);
if (match.Success ==true)
{
Console.WriteLine("True=>Chinese Word Only");
}else
{
Console.WriteLine("False");
}
input = "Angela";
match = Regex.Match(input, patternZh);
Console.WriteLine("測試:" + input);
if (match.Success == true)
{
Console.WriteLine("True=>Chinese Word Only");
}
else
{
Console.WriteLine("False");
}
input = "中文名";
match = Regex.Match(input, patternZh);
Console.WriteLine("測試:" + input);
if (match.Success == true)
{
Console.WriteLine("True=>Chinese Word Only");
}
else
{
Console.WriteLine("False");
}