Replace text variables.

@param string     $text
@param array|null $replacements

@return string
558722
protected function replace($text, $replacements)
    {
        if (is_array($replacements)) {
            foreach ($replacements as $var => $replacement) {
                $regex = str_replace('key', preg_quote($var, '/'), $this->translateReplaceRegex);
                $text = preg_replace($regex, $replacement, $text);
            }
        }
        return $text;
    }
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);
    }
562318
def var_replace(self, text):
        
        result = text
        for var in self._vardict:
            result = result.replace("@{}".format(var), self._vardict[var])
        return result
435756
public function scan($text, &$replaceList = null)
    {
        $scan_result = array();
        $text = $this->_matchCase ? $text : strtolower($text);
        $text_length = mb_strlen($text);
        for ($i = 0; $i < $text_length; $i++) {
            $word_length = $this->_check($text, $i, $text_length);
            if ($word_length > 0) {
                $word = mb_substr($text, $i, $word_length);
                $scan_result[] = $word;
                $replaceList !== null && $replaceList[] = str_repeat($this->_escapeChar, mb_strlen($word));
                $i += $word_length - 1;
            }
        }
        return $scan_result;
    }
582474
protected static function removeUnusedPlaceholders($text)
    {
        $text = preg_replace(self::PLACEHOLDER_REGEX, '', $text);
        return preg_replace(self::COMMAND_REGEX, '', $text);
    }
647091
public function setWriteTranslations(array $replacements)
    {
        foreach ($this->translations as $search => $replace) {
            if (!isset($replacements[$search])) {
                $this->removeFilter($search);
                unset($this->translations[$search]);
            }
        }

        foreach ($replacements as $search => $replace) {
            if (!isset($this->translations[$search])) {
                $this->addFilter(
                    $this->replacementFactory->createFilter($search, $replace), $search
                    );
                $this->translations[$search] = true;
            }
        }
    }
456319
private static function replace(string $text, Array $data = null): string {
    if (!empty($text) && count($data)) {
      if ($metaText = (new ReplaceText())->replace($text, $data)) {
        $text = $metaText;
      }
    }
    return $text;
  }
11169
public function replaceAll(Text $text, $pattern, $replacement)
    {
        $input = array(
            'text' => $text,
            'pattern' => $pattern,
            'replacement' => $replacement,
        );
        $this->commandInvoker->run('replace_all', $input);
    }
781633
protected function __fixPersianString($text){
       
       if(is_null($text))
          return null;
       $replacePairs = array(
                chr(0xD9).chr(0xA0) => chr(0xDB).chr(0xB0),
                chr(0xD9).chr(0xA1) => chr(0xDB).chr(0xB1),
                chr(0xD9).chr(0xA2) => chr(0xDB).chr(0xB2),
                chr(0xD9).chr(0xA3) => chr(0xDB).chr(0xB3),
                chr(0xD9).chr(0xA4) => chr(0xDB).chr(0xB4),
                chr(0xD9).chr(0xA5) => chr(0xDB).chr(0xB5),
                chr(0xD9).chr(0xA6) => chr(0xDB).chr(0xB6),
                chr(0xD9).chr(0xA7) => chr(0xDB).chr(0xB7),
                chr(0xD9).chr(0xA8) => chr(0xDB).chr(0xB8),
                chr(0xD9).chr(0xA9) => chr(0xDB).chr(0xB9),
                chr(0xD9).chr(0x83) => chr(0xDA).chr(0xA9),
                chr(0xD9).chr(0x89) => chr(0xDB).chr(0x8C),
                chr(0xD9).chr(0x8A) => chr(0xDB).chr(0x8C),
                chr(0xDB).chr(0x80) => chr(0xD9).chr(0x87) . chr(0xD9).chr(0x94));
       return strtr($text, $replacePairs);
   }
913329
protected function replaceWithVariables($string)
    {
        if (preg_match_all('/:([a-z_]+)/', $string, $matches)) {
            list(
                $original,
                $vars
            ) = $matches;

            foreach ($vars as $key => $var) {
                if (isset($this->vars[$var])) {
                    $string = str_replace($original[$key], $this->vars[$var], $string);
                }
            }
        }

        return $string;
    }
1280862
function (text, replacements) {
        'use strict';
        var keys = getKeysFromTemplate(text),//Object.keys(replacements),
            len = keys.length,
            i = 0,
            key,
            value;
        while (i < len) {
            key = keys[i];
            if (key.indexOf('.') !== -1) {
                value = getNestedValue(replacements, key);
            } else {
                value = replacements[key];
            }
            if (value) {
                text = text.split('{' + key + '}').join(value);
            }
            i += 1;
        }
        return text;
    }
637177
protected function replacePlaceholders($string, array $variables)
    {
        foreach ($variables as $variableName => $variableValue) {
            $string = str_replace('<' . $variableName . '>', $variableValue, $string);
        }

        return $string;
    }
866013
private function replace(string $text = null, array $data = null)
    {
        if ($text && is_array($data) && sizeof($data) > 0 && $text && is_numeric(array_keys($data)[0])) {
            return vsprintf($text, $data);
        } elseif ($text && !is_null($data) && sizeof($data) > 0) {
            return strtr($text, $data);
        } else {
            return $text ?? null;
        }
    }
319538
function replaceBadCharacters( text ) {
  var i, repl;
  for ( i = 0; i < rLen; i++ ) {
    repl = replacements[i];
    text = text.replace( repl[0], repl[1] );
  }
  return text;
}
840098
protected function replaceWithData($text, array $matches, array $data)
    {
        list($search, $replace) = $this->getSearchAndReplace($matches, $data);

        return str_replace($search, $replace, $text);
    }
59058
protected function replaceInText($text)
	{
		$text = str_replace("##YEAR##", date('Y'), $text);
		$text = str_replace("##DATE##", date('Y-m-d'), $text);

		return $text;
	}
1300234
public function replace(string $text, array $placeholders = []): string
    {
        if (!$placeholders) {
            return $text;
        }
        return strtr(strtr($text, $this->getPlainArgs($placeholders)), $this->getEscapedArgs($placeholders));
    }