正则表达式=》判断中文字

//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"); }
上一篇:微信小程序开发


下一篇:Adobe Premiere Pro将加入AI生成式功能,以提高视频编辑的效率;OpenAI宣布在东京设立亚洲首个办事处