Nodejs String Replace replaceAll(a, b)

Here you can find the source of replaceAll(a, b)

Method Source Code

String.prototype.replaceAll = function(a, b) {
    var toReturn = this;
    var temp;//from   w w w  .  j  a  va  2  s  .  c o  m
    do {
        temp = toReturn;
    } while(
        (toReturn = toReturn.replace(a, b)) !== temp
    );
    return toReturn;
};

Related

  1. replaceAll($oldText,$replaceText)
    String.prototype.replaceAll = function($oldText,$replaceText){
      return this.replace(new RegExp($oldText,"gm"),$replaceText);
    };
    
  2. replaceAll()
    String.prototype.replaceAll = function() {
        var target = this;
        return target.split(" ").join("-");
    };
    String.prototype.numberToString = function() {
        var target = this;
        var storing = "";
        var strlength = target.length;
        var numbers = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
    ...
    
  3. replaceAll(AFindText, ARepText)
    String.prototype.replaceAll = function(AFindText, ARepText) {
        var raRegExp = new RegExp(AFindText, "g");
        return this.replace(raRegExp, ARepText);
    };
    
  4. replaceAll(AFindText, ARepText)
    String.prototype.replaceAll = function (AFindText, ARepText) {
        return this.replace(new RegExp(AFindText, "gm"), ARepText)
    };
    
  5. replaceAll(_old, _new)
    String.prototype.replaceAll = function(_old, _new){
        return this.replace(new RegExp(_old, 'g'), _new)
    };
    
  6. replaceAll(de, para)
    String.prototype.replaceAll = function (de, para) {
      var str = this;
      var pos = str.indexOf(de);
      while (pos > -1) {
        str = str.replace(de, para);
        pos = str.indexOf(de);
      return (str);
    };
    ...
    
  7. replaceAll(exp, newStr)
    String.prototype.replaceAll = function (exp, newStr) {
        return this.replace(new RegExp(exp, "gm"), newStr);
    };
    
  8. replaceAll(f,r)
    String.prototype.replaceAll = function(f,r) {
        return this.split(f).join(r);
    };
    
  9. replaceAll(find, replace)
    String.prototype.replaceAll = function (find, replace) {
        var str = this;
        return str.replace(new RegExp(find, 'g'), replace);
    };