Javascript String replaceAll(oldString, replacement)

Description

Javascript String replaceAll(oldString, replacement)

String.prototype.replaceAll = function (oldString, replacement) {
    var a = this;

    while (a.indexOf(oldString) != -1) {
        a = a.replace(oldString, replacement);
    }//w  w w  .  j a va 2  s.co m

    return a;
}



PreviousNext

Related