简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

去除html标签删除html示例代码

来源:易贤网   阅读:1043 次  日期:2014-10-08 15:05:22

温馨提示:易贤网小编为您整理了“去除html标签删除html示例代码”,方便广大网友查阅!

代码如下:

/// <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技术专栏

更多信息请查看网络编程
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:dataset与datatable的区别示例介绍
下一篇:根据控件id得到控件并对该控件进行操作
易贤网手机网站地址:去除html标签删除html示例代码
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!