蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

js下正则表达式的问题

在html代码里,我想把在标签里的>符号替换为>
如<span onclick="if (1 > 2) {} if(2 > 3) {}"></span>
变为<span onclick="if (1 &gt; 2) {} if(2 &gt; 3) {}"></span>
用正则有办法么?

[html]<p>处理前:<textarea name=ab style="width:500px;height:400px"><span onclick="if (1 > 2) {} if(2 > 3) {}"></span></textarea>
<p><button onclick=did()>处理</button>
<p>处理后:<textarea name=bc style="width:500px;height:400px"></textarea>
<script>
function did()
{tempstr=ab.value
re=/<.*?"([^"]+)".*?>/
qq=tempstr.match(re)
tempsubstr=qq[1].replace(/>/g,"&gt;")
bc.value=tempstr.replace(qq[1],tempsubstr)
}
</script>[/html]




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com