判断中文字
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");
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
