C# 正则表达式输入验证必须为汉字

例子:

string str = "测试";
string reg = @"^[\u4e00-\u9fa5]*$";
Match match = Regex.Match(str,reg);
if (match.Success)
{
Console.WriteLine("输入正确!");
}
else
{
Console.WriteLine("输入有误!");
}

猜你喜欢

转载自www.cnblogs.com/qudeqiang/p/9156584.html