读书人

问一个关于去除lt;htmlgt;标签的有关问题

发布时间: 2012-09-05 15:19:34 作者: rapoo

问一个关于去除<html>标签的问题
我已经写好了 我不知道调用 求大神教我aspx页面调用这个类 下面是我写的代码
能详细的最好 谢谢 我的是内容是在girdview里显示 求大神给出页面调用代码
public static string ReplaceHtml(string html)
{
Regex regex = new Regex(@"<Applet(.*?)>((.|\n)*?)</Applet(\s)*>", RegexOptions.IgnoreCase);
html = regex.Replace(html, ""); //过滤<Applet></Applet>标记

regex = new Regex(@"<script(.*?)>((.|\n)*?)</script(\s)*>", RegexOptions.IgnoreCase);
html = regex.Replace(html, ""); //过滤<script></script>标记

regex = new Regex(@"<style(.*?)>((.|\n)*?)</style(\s)*>", RegexOptions.IgnoreCase);
html = regex.Replace(html, ""); //过滤<style></style>标记

string temp = Regex.Replace(html, "<[^>]*>", "");
temp = temp.Replace(" ", " ");
temp = temp.Replace("\r\n", " ");
temp = temp.Replace("\r", " ");
temp = temp.Replace("\n", " ");
temp = temp.Replace("\t", " ");

temp = temp.Replace("—", "—");

temp = Regex.Replace(temp, @"(\s){3,}", " ");

regex = new Regex(@"('(.*?)(\"")>)", RegexOptions.Multiline);
temp = regex.Replace(temp, ""); //过滤<style></style>标记

return temp;
}

[解决办法]
如果要调用方法需要把这一项改成模板列

你直接把我写的代码中的title换成你的内容content就可以了

读书人网 >asp.net

热点推荐