My Space

导航

正则表达式提取中文

如果在一段字符串文本中得到所有中文字符的话,可以使用下边程序来实现。 

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 on 2010-02-14 23:36  alronzhang  阅读(7680)  评论(0编辑  收藏  举报