把上面{keywords}替换成你的关键字,注意把{}也替换掉,我是为了让你看明白换哪才加的{}。
然后你找到匹配上面的正则的地方后替换成你想替换的字符串就好了,全部替换记得用全局修饰符
<head><script language="javascript">
var G=document.getElementById
function window_load(){
var strHTML = ""// document.body.innerHTML
strHTML += "<html>"
strHTML += " <head>"
strHTML += " </head>"
strHTML += " <body>"
strHTML += " <font color='red'>test1</font><br />"
strHTML += " <font size='18'>test2</font><br />"
strHTML += " <font >test3</font><br />"
strHTML += " <font></font>"
strHTML += " </body>"
strHTML += "</html>"
var reg = /<(font)\s*[^<>]*>[^<>]*<\/\1\s*>/ig
var aryResult = strHTML.match(reg)
alert("用match方法匹配 ,结果:\n\n" + aryResult.join("\n"))
}
</script>
</head>
<body onload="window_load()"> \
<!--
<font color='red'>test1</font><br />
<font size='18'>test2</font><br />
<font >test3</font><br />
<font></font>
-->
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)