/**
* 向字符串对象中追加replaceAll方法
* @param {} reallyDo
* @param {} replaceWith
* @param {} ignoreCase
* @return {}
*/
String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
} else {
return this.replace(reallyDo, replaceWith);
}
} 向字符串对象中追加replaceAll方法
最新推荐文章于 2025-01-12 20:43:30 发布
本文介绍了一种向JavaScript String对象原型中扩展replaceAll方法的方法,该方法可以接收正则表达式作为参数,并支持忽略大小写的选项。这为字符串操作提供了更大的灵活性。
1862

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



