string扩展api--replaceAll

replaceAll

 

 

 /*
@name replaceAll  把某一个元素替换成新的元素
@param source 操作的string
@param s1  被替换的
@param s2  替换为的
@return  已经被替换过的新的string
*/
function replaceAll(source,s1,s2){
     return source.replace(new RegExp(s1,"gm"),s2);
}
 

 

 

你可能感兴趣的:(String,replaceAll)