Replaces all the occurences which match the given pattern with the given
replacement.

@param Text   $text
@param string $pattern
@param string $replacement

@api
11169
public function replaceAll(Text $text, $pattern, $replacement)
    {
        $input = array(
            'text' => $text,
            'pattern' => $pattern,
            'replacement' => $replacement,
        );
        $this->commandInvoker->run('replace_all', $input);
    }
172860
private static void checkPreconditions(final Pattern pattern, final String replacement) {
        if(pattern == null ) {
            throw new NullPointerException("regex should not be null");
        }
        
        if(replacement == null) {
            throw new NullPointerException("replacement should not be null");
        }
    }
952508
protected function addPatternAndReplacement($pattern, $replacement)
    {
        $instance = new \stdClass();
        $instance->pattern = $pattern;
        $instance->replacement = $replacement;
        $this->patternsAndReplacements[] = $instance;
    }
1348935
function replace($search,$replace){
		$this->_String = $this->toString();
		return parent::replace($search,$replace);
	}
443852
public static String substitute(Pattern pattern, String text, I_CmsRegexSubstitution sub) {

        StringBuffer buffer = new StringBuffer();
        Matcher matcher = pattern.matcher(text);
        while (matcher.find()) {
            matcher.appendReplacement(buffer, sub.substituteMatch(text, matcher));
        }
        matcher.appendTail(buffer);
        return buffer.toString();
    }
1182027
public function replaceBeginning($search, $replacement)
    {
        return $this->regexReplace
        (
            '^'.preg_quote($search, '/'),
            UTF8::str_replace('\\', '\\\\', $replacement)
        );
    }
1286154
public static String replaceAll(String str, String match, String replacement) {
        String newStr = str;
        int i = newStr.indexOf(match);
        while (i >= 0) {
            newStr = newStr.substring(0, i) + replacement
                    + newStr.substring(i + match.length());
            i = newStr.indexOf(match);
        }
        return newStr;
    }
34292
public function replace(string $search, string $replacement): self
    {
        if (!$this->contains($search)) {
            return $this;
        }

        return $this
            ->split($search)
            ->join($replacement);
    }
209041
public function filter($string, $replacement = '')
    {
        if ($replacement !== '') {
            return preg_replace_callback(static::REGEX_ANSI, function ($matches) use ($replacement) {
                return str_repeat($replacement, mb_strlen($matches[0]));
            }, $string);
        }
        return preg_replace(static::REGEX_ANSI, $replacement, $string);
    }
807574
private String stringReplace(String text, String target, String replacement) {
		return Pattern.compile(target.toString(), Pattern.LITERAL).matcher(
				text).replaceAll(replacement);
	}
412603
public function replace($search, $replacement) {
        $regexEncoding = mb_regex_encoding();
        mb_regex_encoding($this->encoding);

        // Don't want the args being parsed as regex
        $search = preg_quote($search);
        $replacement = preg_quote($replacement);

        $str = mb_ereg_replace($search, $replacement, $this->str);
        mb_regex_encoding($regexEncoding);

        return self::create($str, $this->encoding);
    }
28942
public function replace(string $find, string $replace): Stringable
    {
        return new static(str_replace($find, $replace, $this->string));
    }
1371768
protected function eregReplace($pattern, $replacement, $string, $option = 'msr')
	{
		trigger_error('Function ' . __METHOD__ . ' not implemented yet');

		static $functionExists;
		if ($functionExists === null) {
			$functionExists = function_exists('\mb_split');
		}

		if ($functionExists) {
			return \mb_ereg_replace($pattern, $replacement, $string, $option);
		} else if ($this->supportsEncoding()) {
			$option = str_replace('r', '', $option);
			return \preg_replace("/$pattern/u$option", $replacement, $string);
		}
	}
330937
private static function runInflection($text, $rules)
    {
        if(in_array($text, self::$noPlurals)) {
            return $text;
        }
        foreach($rules as $rule) {
            if(preg_match($rule[0], $text, $matches)) {
                return substr($text, 0, strlen($text) - strlen($matches['remove'] ?? '')) . $rule[1];
            }
        }
    }
936812
public static String replaceAll(CharSequence content, String regex, String replacementTemplate) {
		final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
		return replaceAll(content, pattern, replacementTemplate);
	}
255827
public static String replace(final CharSequence target, final CharSequence replacement, final String string) {
    return Pattern.compile(quote(target.toString())/*
                                                    * , Pattern.LITERAL jdk 1.4
                                                    */).matcher(string).replaceAll(
    /* Matcher. jdk 1.4 */quoteReplacement(replacement.toString()));
  }
293733
public static function for($pattern, $replacement, $subject, $limit)
    {
        try {
            list($result, $count) = is_callable($replacement) ?
                static::doReplacementWithCallable($pattern, $replacement, $subject, $limit) :
                static::doReplacement($pattern, $replacement, $subject, $limit);
        } catch (Exception $exception) {
            throw RegexFailed::replace($pattern, $subject, $exception->getMessage());
        }

        if ($result === null) {
            throw RegexFailed::replace($pattern, $subject, static::lastPregError());
        }

        return new static($pattern, $replacement, $subject, $result, $count);
    }