通过正则表达式筛选出字符串中的汉字部分

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();
}

posted @ 2021-11-19 16:42  一起看海吗  阅读(396)  评论(0)    收藏  举报