复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19static void Main(string[] args) { string str = "asd=-.我是中文{asdasd"; Console.WriteLine(GetChineseWord(str)); Console.ReadKey(); } public static string GetChineseWord(string oriText) { string x = @"[u4E00-u9FFF]+"; MatchCollection Matches = Regex.Matches (oriText, x, RegexOptions.IgnoreCase); StringBuilder sb = new StringBuilder(); foreach (Match NextMatch in Matches) { sb.Append(NextMatch.Value); } return sb.ToString(); }
很简单,不想废话,最终控制台输出的就是“我是中文”这几个字
转载于:https://www.cnblogs.com/mi21/p/9798218.html
最后
以上就是鳗鱼中心最近收集整理的关于正则表达式之提取中文的全部内容,更多相关正则表达式之提取中文内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复