首页 > 代码库 > Js扩展方法ReplaceAll

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

Js扩展方法ReplaceAll