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);
}
理解replaceAll函数在字符串操作中的应用
本文详细解释了JavaScript中的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);
}
211

被折叠的 条评论
为什么被折叠?