js不提供replaceAll方法,要用正规表达式实现
第一种:
String.prototype.replaceAll = function(s1,s2){
return this.replace(new RegExp(s1,"gm"),s2);
}
第二种:
str =str.replace(/&/g,"@");//将str串中的&替换成@
转载自:http://www.csdn.net/article/a/2009-12-08/258255