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

Html中截切文章内容,造成标签不全的问题

2015-04-29 13:02 351 查看
把标签全部进行替换

public static string ReplaceHtmlTag(string html, int length = 0)
{
string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");
strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");

if (length > 0  && strText.Length > length)
return strText.Substring(0, length);

return strText;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: