// 内部调用
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);
}
}
/**
* JavaScript的replaceAll方法.
* @param sourceStr 源字符串.
* @param reallyDo 待替换的字符串.
* @param replaceWith 替换成的字符串.
* @return 返回替换后的新字符串.
*/
function replaceAll(sourceStr, reallyDo, replaceWith){
return sourceStr.replaceAll_(reallyDo, replaceWith);
}