您的位置:首页 > Web前端 > HTML

C#获取html中纯文本

2016-08-05 14:58 609 查看
C#获取html中纯文本

/// <summary>
/// 获取html中纯文本
/// </summary>
/// <param name="html">html</param>
/// <returns>纯文本</returns>
public static string GetHtmlText(string html)
{
html = System.Text.RegularExpressions.Regex.Replace(html, @"<\/*[^<>]*>", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
html = html.Replace("\r\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "");
return html;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c# html 纯文本