C#正則表達式提取字符串漢字部分

using System.Text.RegularExpressions;
   
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();
}


轉載優特建站:http://www.youtiy.com/Articles/Item.aspx?Id=138

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章