不说了,看这个测试用的js代码好了
<html>
<body>
<form name="form1">
<p>原字符串:<input type="text" name="t1" size=60">
<p>替换第一个符合的字符:<input type="text" name="t2" size=60">
<p>替换所有符合的字符:<input type="text" name="t3" size=60">
</form>
<script language="JavaScript">
s="<p>aaa</p><p>bbb</p>";
form1.t1.value="/s;
s=s.replace(""<","< ");
s=s.replace(">"," >");
form1.t2.value="/s;
s=s.replace(/\</g,""< ");
s=s.replace(/\>/g," >");
form1.t3.value=s;
</script>
</body>
</html>