Replace text
@param {string} text - Text including handlebar expression
@param {Object} values - Replaced values
@returns {string} Replaced text
772839
function(text, values) {
        return text.replace(/\{\{(\w*)\}\}/g, function(value, prop) {
            return values.hasOwnProperty(prop) ? values[prop] : '';
        });
    }
83809
public MultiChangeBuilder<PS, SEG, S> insertText(int position, String text) {
        return replaceText(position, position, text);
    }
1089580
public function replace($text)
    {
        preg_match_all($this->pattern, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
        $delta = 0;
        foreach ($matches as $match)
        {
            $stringsOnly = array();
            foreach ($match as $info)
            {
                $stringsOnly []= $info[0];
            }
            $replace = call_user_func($this->callback, $stringsOnly);
            if (false === $replace || null === $replace)
            {
                continue;
            }

            $text = substr_replace($text, $replace, $match[0][1] + $delta, strlen($match[0][0]));
            $delta += strlen($replace) - strlen($match[0][0]);
        }

        return $text;
    }
497073
public function replace(string $text, Array $data): string {
    $replaceText = $text;
    if (!empty($text) && count($data)) {
      foreach ($data as $key => $value) {
        $replaceText = preg_replace("#(\{data\:{$key}\})#i", $value, $replaceText);
      }
    }
    return $replaceText;
  }
807574
private String stringReplace(String text, String target, String replacement) {
		return Pattern.compile(target.toString(), Pattern.LITERAL).matcher(
				text).replaceAll(replacement);
	}
670084
function replaceWithPlainText(selector, regex) {
  return selector.replace(regex, function(match) {
    return Array(match.length + 1).join('A');
  });
}
1130964
function replaceText(id, text) {
    var element = document.getElementById(id)
    if (null == element) {
//      alert("error: can't find element with id '" + id + "'")
        return
    }

    element.innerHTML = text
}
514171
function replaceVars(value, vars) {
        if (typeof value != "string") {
          value = value(vars);
        } else if (vars) {
          value = value.replace(/%(\w+)/g, function (str, name) {
            return vars[name] || str;
          });
        }

        return value;
      }
222839
def replace(self, text):
        """"""
        for (pattern, repl) in self.patterns:
            text = re.subn(pattern, repl, text)[0]
        return text
111612
function(text, curr, total) {
		return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total);
	}
392084
function(template, values, pattern) {
      pattern = pattern || /\{([^{}]*)\}/g;
      return template.replace(pattern, function(a, b) {
        var p = b.split('.'),
          r = values;
        try {
          for (var s in p) {
            if (p.hasOwnProperty(s)) {
              r = r[p[s]];
            }
          }
        } catch (e) {
          r = a;
        }
        return (typeof r === 'string' || typeof r === 'number') ? r : a;
      });
    }
601189
function replace(regex, source, options) {
  var valueOrFn = getValueOrMatchFn(options.value)
  source.replace(regex, function () { return '' })
  return source.replace(regex, valueOrFn)
}
757656
function replacePlaceholder(str, value, _state) {
	if (typeof str === 'string') {
		const ranges = findUnescapedTokens(str, placeholder);
		if (ranges.length) {
			if (_state) {
				_state.replaced = true;
			}

			str = replaceRanges(str, ranges, value);
		}
	}

	return str;
}
1329139
function str_replace(names, values, str) {
  names.forEach((name, idx) => {
    str = str.replace(names[idx], values[idx]);
  });
  return str;
}
858323
public String replace(CharSequence text)
    {
        if (text == null)
        {
            return null;
        }
        try
        {
            StringBuilder sb = new StringBuilder();
            replace(text, sb);
            return sb.toString();
        }
        catch (IOException ex)
        {
            throw new IllegalArgumentException();
        }
    }
804885
function replaceTextWithMap(string, map) {
    // break the words into tokens using _ and words themselves
    const tokens = XRegExp.match(string, /([a-z0-9_]+)/ig);
    // for all the tokens replace it in string
    for(let token of tokens) {
      // try to replace only if the key exists in the map else skip over
      if(map.hasOwnProperty(token)) {
        string = replaceAll(token, map[token], string);
      }
    }
    return string;
  }
995774
function stringSupplant(str, values) {
		return str.replace(/#\{(\w+)\}/g, function(match, name) {
			return values[name] || "";
		});
	}