获取html中的全部中文文本

 /// <summary>
        /// 获取文本中的全部中文文本
        /// </summary>
        /// <param name="oriText"></param>
        /// <returns></returns>
    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-12-24 17:30  极客船长  阅读(304)  评论(0编辑  收藏  举报