Nodejs Utililty Methods String Replace

List of utility methods to do String Replace

Description

The list of methods to do String Replace are organized into topic(s).

Method

replaceAll(AFindText, ARepText)
String.prototype.replaceAll = function(AFindText, ARepText) {
    var raRegExp = new RegExp(AFindText, "g");
    return this.replace(raRegExp, ARepText);
};
replaceAll(AFindText, ARepText)
String.prototype.replaceAll = function (AFindText, ARepText) {
    return this.replace(new RegExp(AFindText, "gm"), ARepText)
};
replaceAll(_old, _new)
String.prototype.replaceAll = function(_old, _new){
    return this.replace(new RegExp(_old, 'g'), _new)
};
replaceAll(a, b)
String.prototype.replaceAll = function(a, b) {
    var toReturn = this;
    var temp;
    do {
        temp = toReturn;
    } while(
        (toReturn = toReturn.replace(a, b)) !== temp
    );
    return toReturn;
...
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);
};
...
replaceAll(exp, newStr)
String.prototype.replaceAll = function (exp, newStr) {
    return this.replace(new RegExp(exp, "gm"), newStr);
};
replaceAll(f,r)
String.prototype.replaceAll = function(f,r) {
    return this.split(f).join(r);
};
replaceAll(find, replace)
String.prototype.replaceAll = function (find, replace) {
    var str = this;
    return str.replace(new RegExp(find, 'g'), replace);
};
replaceAll(find, replace)
String.prototype.replaceAll = function(find, replace) {
  return this.replace(new RegExp(find, 'g'), replace);
};
replaceAll(find, replace)
String.prototype.replaceAll = function (find, replace) {
    var str = this;
    return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace);
};