function Striphtml(html)
…{
html = 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;
}
欢迎大家阅读《利用正则表达式移除Html标签(javascri…_js》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码