作者共发了1篇帖子。 内容转换:不转换▼
 
点击 回复
102 0
【原创】正则替换程序
一派护法 十九级
1楼 发表于:2010-9-18 22:24
<!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>

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
(快捷键:Ctrl+Enter)
 

本帖信息

点击数:102 回复数:0
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2010-9-18 22:24
 
©2010-2024 Arslanbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。