Javascript String replaceAll(reallyDo, replaceWith, ignoreCase)

Description

Javascript String replaceAll(reallyDo, replaceWith, ignoreCase)


String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
    if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
        return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi" : "g")), replaceWith);
    } else {//from   w  w  w . ja  v a 2s  .  c o m
        return this.replace(reallyDo, replaceWith);
    }
};



PreviousNext

Related