|
蓝森林 http://www.lslnet.com 2006年8月25日 8:28
js下正则表达式的问题
在html代码里,我想把在标签里的>符号替换为>
如<span onclick="if (1 > 2) {} if(2 > 3) {}"></span>
变为<span onclick="if (1 > 2) {} if(2 > 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,">")
bc.value=tempstr.replace(qq[1],tempsubstr)
}
</script>[/html] |
|