Js扩展方法ReplaceAll

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);
}
}

posted @ 2016-09-30 08:47  芜明-追星  阅读(214)  评论(0编辑  收藏  举报