一,JavaScript 替换所有符合条件字符 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); } }; //引用示例: var str='223llla'; str=str.replaceAll('22','33'); console.log(str);//333llla