C#匹配HTML标签,正则表达式谁会?

来源:百度知道 编辑:UC知道 时间:2024/05/12 10:35:28
很简单,就是想要一下一对标签之间的内容

比如:<dl>想要的内容</dl> ,<a>想要的内容</a> 。。。

谁能帮小弟一下,谢谢啦

JS:
function StripHtml(html)
{
var scriptregex = "<scr" + "ipt[^>.]*>[sS]*?</sc" + "ript>";
var scripts = new RegExp(scriptregex, "gim");
html = html.replace(scripts, " ");

//Stripts the <style> tags from the html
var styleregex = "<style[^>.]*>[sS]*?</style>";
var styles = new RegExp(styleregex , "gim");
html = html.replace(styles, " ");

//Strips the HTML tags from the html
var objRegExp = new RegExp("<(.| )+?>", "gim");
var strOutput = html.replace(objRegExp, " ");

//Replace all < and > with < and >
strOutput = strOutput.replace(/</, "<");
strOutput = strOutput.replace(/>/, ">");

objRegExp = null;
return strOutput;