Replace a single placeholder.

@param string $body
@param string $valueMatch
@param string $replacer
@return string
421608
protected function replace($body, $valueMatch, $replacer)
    {
        $body = str_replace('{'.$replacer.'}', $valueMatch, $body);

        return $body;
    }
226758
protected function replacePlaceHolder($string)
    {
        foreach ($this->placeHolders as $key => $val) {
            $string = str_replace($key, $val, $string);
        }

        return $string;
    }
1300234
public function replace(string $text, array $placeholders = []): string
    {
        if (!$placeholders) {
            return $text;
        }
        return strtr(strtr($text, $this->getPlainArgs($placeholders)), $this->getEscapedArgs($placeholders));
    }
263396
def fill_placeholders (out)
      re = Regexp.new('%' + @replacement_hash + '%(\d+)%')
      out.gsub re do |m|
        m.gsub!(re, "\\1")
        @placeholders[m.to_i]
      end
    end
1343781
protected static function replacePlaceholder(&$str, $uniqid, $index)
	{
		$str = preg_replace_callback(
			'(' . preg_quote($uniqid) . '(.))',
			function ($m) use ($index)
			{
				// Replace with $1 where unambiguous and ${1} otherwise
				if (is_numeric($m[1]))
				{
					return '${' . $index . '}' . $m[1];
				}
				else
				{
					return '$' . $index . $m[1];
				}
			},
			$str
		);
	}
191053
public static function replaceFirst(string $subject, string $search, string $replace, bool $caseSensitive = true): string
    {
        $pos = $caseSensitive ? mb_strpos($subject, $search) : mb_stripos($subject, $search);
        if ($pos === false) {
            return $subject;
        }

        return substr_replace($subject, $replace, $pos, mb_strlen($search));
    }
283914
public function replacePlaceholders($text, $placeholders = [])
    {
        $parameters = $this->serializer->serialize([Options::SERIALIZE_MINIMAL]);
        $now = new \DateTime();
        $keys = [
            '%platform_name%',
            '%platform_url%',
            '%date%',
            '%datetime%',
        ];
        $values = [
            $parameters['display']['name'],
            $parameters['internet']['platform_url'],
            $now->format('Y-m-d'),
            $now->format('Y-m-d H:i:s'),
        ];

        foreach ($placeholders as $key => $value) {
            $keys[] = '%'.$key.'%';
            $values[] = $value;
        }

        return str_replace($keys, $values, $text);
    }
881806
public function replaceOneValue($search, $replacement = ''): self
    {
        $array = $this->getArray();
        $key = \array_search($search, $array, true);

        if ($key !== false) {
            $array[$key] = $replacement;
        }

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
162680
public static function replaceLast(string $subject, string $search, string $replace, bool $caseSensitive = true): string
    {
        $pos = $caseSensitive ? mb_strrpos($subject, $search) : mb_strripos($subject, $search);
        if ($pos === false) {
            return $subject;
        }

        return substr_replace($subject, $replace, $pos, mb_strlen($search));
    }
72515
public static function fillPlaceholders(string $msg, array $values)
    {
        foreach ($values as $key => $value)
            $msg = str_replace('{' . $key . '}', self::str($value), $msg);
        return $msg;
    }
193942
protected function replaceElementContents($contents, PlaceholderContainer $placeholderContainer)
    {
        $htmlTags = implode('|', $this->htmlPlaceholderTags);

        $pattern = '/
            (
                <(' . $htmlTags . ')                    # Match html start tag and capture
                    (?:
                        [^"\'>]*|"[^"]*"|\'[^\']*\'
                    )*                                  # Match all attributes
                >                                       # Match end of tag
            )
            (
                (?:                                     # Negotiate this part
                    (?!<\/\2>)                          # Negative look ahead for the end tag
                    .                                   # Match everything if not the end tag 
                )*+                                     # Possessive quantifier which will prevent backtracking
            )
            (<\/\2>)                                    # Match end tag by back referencing the start tag
            /xis';

        return preg_replace_callback($pattern, function ($match) use ($placeholderContainer) {
            return $match[1].$placeholderContainer->createPlaceholder($match[3]).$match[4];
        }, $contents);
    }
932956
public function replace($replace, $key, $value): self
    {
        $that = clone $this;

        return $that->remove($replace)
            ->set($key, $value);
    }
596780
function replace(searchValue, replaceValue) {
        var O = requireObjectCoercible(this);
        var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
        return replacer !== undefined
          ? replacer.call(searchValue, O, replaceValue)
          : nativeReplace.call(String(O), searchValue, replaceValue);
      }
676359
function replacePlaceholders(src, options) {
	return Object.keys(placeholders).reduce((out, placeholder) => {
		return out.replace(new RegExp(`${placeholder}`, 'g'), placeholders[placeholder]);
	}, src);
}
1030240
public static function replace(string $str, string $find, $replace = ''): string
    {
        return ($position = strpos($str, $find)) !== false ? substr_replace($str, $replace, $position, strlen($find)) : $str;
    }
1230949
protected function replaceTemplate($search, $replace, &$subject)
    {
        $subject = $this->strReplace($search, $replace, $subject);

        return $this;
    }
804245
public static function replaceStringPlaceholders($text, $deletePlaceholders = false)
    {
        if (is_string($text)) {
            // Fast pre-check, to optimize performance
            if (strpos($text, "_") !== false) {
                $replaceStringPlaceholders = function ($matches) use ($deletePlaceholders) {
                    $result = "";
                    if (isset(self::$replacements[$matches[1]])) {
                        $result = self::$replacements[$matches[1]];
                        $result = str_replace(
                            ['_STRING_CSSLINEBREAK_', '_STRING_ESCAPEDDOUBLEQUOTE_', '_STRING_ESCAPEDSINGLEQUOTE_'],
                            ["\\\n", '\\"', "\\'"],
                            $result
                        );
                        if ($deletePlaceholders === true) {
                            unset(self::$replacements[$matches[1]]);
                        }
                    }
                    return $result;
                };
                $text = preg_replace_callback('/(?:_STRING_([a-f0-9]{32})_)/', $replaceStringPlaceholders, $text);
            }
            return $text;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($text). "' for argument 'text' given."
            );
        }
    }