日期:2014-05-16 浏览次数:20508 次
<script type="text/javascript"> var str = 'bbabadfadg<BR><IMG SRC="IMAGES/xxxx.jgp"><A HREF="FILE/help.html">help</A><P>AAAAA</P><SPAN>00000</SPAN>'; var reg= /[^=<>]+(?=\=)/; str = str.replace(/<[^>]+?>/g, function (s) { if (reg.test(s)) { return reg.exec(s).toLowerCase(); } else return s.toLowerCase(); }); alert(str); </script>
------解决方案--------------------
var str = "bbabadfadg<BR><IMG SRC=\"images/xxxx.jgp\"><A HREF=\"file/help.html\">help</A><P>AAAAA</P><SPAN>00000</SPAN>"; str = str.toLowerCase(); var r = /<[\/]*(a|span).*?>/g; var s = str.match(r); str = str.replace(r,"");
------解决方案--------------------
var r = /<[\/]*(a|span).*?\/(a|span)?>/g;
------解决方案--------------------