String.replaceAll method implementation

String.prototype.replaceAll = function(pcFrom, pcTo){
var i = this.indexOf(pcFrom);
var c = this;

while (i > -1){
c = c.replace(pcFrom, pcTo);
i = c.indexOf(pcFrom);
}
return c;
}

source

Leave a Reply