Nodejs String Replace replaceAll(origin, replace)

Here you can find the source of replaceAll(origin, replace)

Method Source Code

String.prototype.replaceAll = function(origin, replace){
   var regexp = new RegExp(origin,'g');
   return this.replace(regexp,replace);
};

Related

  1. replaceAll(oldString, replacement)
    String.prototype.replaceAll = function (oldString, replacement) {
        var a = this;
        while (a.indexOf(oldString) != -1) {
            a = a.replace(oldString, replacement);
        return a;
    
  2. replaceAll(oldValue, newValue)
    String.prototype.replaceAll = function (oldValue, newValue) {
      return this.replace(new RegExp(oldValue, 'g'), newValue);
    };
    
  3. replaceAll(org, dest)
    String.prototype.replaceAll = function(org, dest) {
      var data = this;
      if (org instanceof Array) {
        org.forEach(function(elm) {
          data = data.split(elm).join(dest);
        });
        return data;
      } else {
        return data.split(org).join(dest);
    ...
    
  4. replaceAll(org, dest)
    String.prototype.replaceAll = function(org, dest) {
        return this.split(org).join(dest);
    
  5. replaceAll(org, tag)
    String.prototype.replaceAll = function(org, tag){
      return this.replace(new RegExp(org, 'g'), tag);
    };
    
  6. 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 {
            return this.replace(reallyDo, replaceWith);
    };
    
  7. 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
        return this.replace(reallyDo, replaceWith);
    };
    
  8. 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
        return this.replace(reallyDo, replaceWith);
    };
    String.prototype.charLength = function() {
      var len = 0;
    ...
    
  9. replaceAll(replace, value)
    String.prototype.replaceAll = function (replace, value) {
        return this.replace(new RegExp(replace, 'g'), value);
    };