Asp.net 替换THML标签
2012-05-18 16:50
190 查看
public static string ChangeHTML(string Htmlstring) { Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase); 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 = Regex.Replace(Htmlstring, @"<img[^>]*>;", "", RegexOptions.IgnoreCase); Htmlstring.Replace("<", ""); Htmlstring.Replace("<", ""); Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim(); return Htmlstring; }
相关文章推荐
- ASP.NET生成静态页面,标签替换方法
- asp.net 正则替换html标签与删除指定字符方法
- ASP.NET正则替换html标签中img src/href
- asp.net 正则替换html标签与删除指定字符方法
- asp.net 替换字符串,正则替换字符串,不区分大小写替换字符串,替换html标签,正则匹配
- asp.net替换html标签的程序
- ASP.NET小收集:获取可替换部分标签
- asp.net的AutoEventWireup标签起什么作用
- asp 替换指定标签内容
- asp.net(c#)读取模板并替换模板字段
- asp.net HTML文件上传标签
- asp.net组件(1):常用标签
- asp.net正则表达式提取网页网址、标题、图片实例以及过滤所有HTML标签实例
- asp.net控件开发(三):处理标签间内容
- Asp.net自定义控件开发任我行(2)-TagPrefix标签
- (ASP.NET )去除字符串中的HTML标签
- C# ASP.NET替换要转化为json的数据中的特殊符号
- aspose.words for asp.net word模版-修改标签-合并单元格
- Asp.net 字符串操作基类(安全,替换,分解等)
- ASP.NET中 HTML标签总结及使用