日期:2014-05-16  浏览次数:20396 次

javascript replaceAll 方法
<html>
<body>

<script>
/**
方法一
String.prototype.replaceAll = function(s1,s2){
return this.replace(new RegExp(s1,"gm"),s2);
}
var t="a and b and f";
alert(t.replaceAll("and","or"));
*/


//方法二
var h="a and b and f";
alert(h.replace(/and/g,"or"));

</script>
</body>
</html>