<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script type="text/javascript"> <!-- function f(){ document.getElementById('button').onclick=function(){ try{ var s=document.form1.textarea.value; var t=document.form1.textarea3.value; var r=eval(s); with(document.form1.textarea2){ value=value.replace(r,t); } }catch(e){ alert(e.message); document.form1.textarea.focus(); return false; } } document.form1.onreset=function(){return confirm("是否要重置已输入的内容?")}; } --> </script> </head> <body onload="f()"> <form id="form1" name="form1" method="post" action=""> <label> 表达式:<br /> <textarea name="textarea" id="textarea" cols="90" rows="3">/#[0-9]+/gi</textarea> </label> <br /> <label> 替换为:<br /> <textarea name="textarea3" id="textarea3" cols="90" rows="3">额</textarea> <br /> 文章:<br /> <textarea name="textarea2" id="textarea2" cols="90" rows="20">#177的 #111发抖 #961飞 #774风格 #454风格 #454发攻防 #413地方</textarea> </label> <p> <label> <input name="button" type="button" id="button" value="替换" /> </label> <label> <input type="reset" name="button2" id="button2" value="重置" /> </label> </p> </form> </body> </html>