代码如下:
/// <summary>
/// 去除html标签
/// </summary>
/// <param name=htmlstring></param>
/// <returns></returns>
public static string deletehtml(string htmlstring)
{
//删除html
htmlstring = regex.replace(htmlstring, @<(.[^>]*)>, , regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @([\r\n])[\s]+, , regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @-->, , regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @<!--.*, , regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(quot|#34);, \, regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(amp|#38);, &, regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(lt|#60);, <, regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(gt|#62);, >, regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(nbsp|#160);, , regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(iexcl|#161);, \xa1, regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(cent|#162);, \xa2, regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(pound|#163);, \xa3, regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&(copy|#169);, \xa9, regexoptions.ignorecase);
htmlstring = regex.replace(htmlstring, @&#(\d+);, , regexoptions.ignorecase);
htmlstring = htmlstring.replace(<, );
htmlstring = htmlstring.replace(>, );
htmlstring = htmlstring.replace(\r\n, );
return htmlstring;
}
中国足彩网信息请查看IT技术专栏
2025国考·省考课程试听报名