JAVASCRIPT:<script language="javascript"> var a=""123456798; var b=""; b=a.replace("56","abcd"); alert(a+"\n替换结果:"+b); </script>
<script language="javascript"> var a="123456798"; var b=""; b=a.replace("56","abcd"); alert(a+"\n替换结果:"+b); </script>呵呵
可以全量替换的:<script type="text/javascript"> function ReplaceDemo(){ var r, re; // 声明变量。 var ss = "The man hit the ball with the bat.\n"; ss += "while the fielder caught the ball with the glove."; re = /The/gi; // 创建正则表达式模式。 r = ss.replace(re, "A"); // 用 "A" 替换 "The"。 alert(r); // 返回替换后的字符串。 } </script>
var a=""123456798;
var b="";
b=a.replace("56","abcd");
alert(a+"\n替换结果:"+b);
</script>
var a="123456798";
var b="";
b=a.replace("56","abcd");
alert(a+"\n替换结果:"+b);
</script>呵呵
function ReplaceDemo(){
var r, re; // 声明变量。
var ss = "The man hit the ball with the bat.\n";
ss += "while the fielder caught the ball with the glove.";
re = /The/gi; // 创建正则表达式模式。
r = ss.replace(re, "A"); // 用 "A" 替换 "The"。
alert(r); // 返回替换后的字符串。
}
</script>