javaScript String replaceAll 实现

定义:

String.prototype.replaceAll = function(s1,s2) {
     return this.replace(new RegExp(s1,"gm"),s2);
}

实例:

将所有的"\"转化为"_"

docpath = docpath.replaceAll("\\\\","_") ;


你可能感兴趣的:(javaScript String replaceAll 实现)