您的位置:首页 > 其它

向字符串对象中追加replaceAll方法

2013-06-13 22:21 92 查看
/**
*  向字符串对象中追加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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: