<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>