Replace all substring in a String - Node.js String

Node.js examples for String:Replace

Description

Replace all substring in a String

Demo Code


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

Related Tutorials