@param string $search
@param string $replace
@param string $subject

@return string
12619
protected function strReplaceOnce(string $search, string $replace, string $subject): string
    {
        $pos = strpos($subject, $search);
        if ($pos === false) {
            return $subject;
        }

        return substr($subject, 0, $pos) . $replace . substr($subject, $pos + strlen($search));
    }
249195
public static function replacePatternWithKeyword(array $subject, $keyword, $pattern = '$1')
    {
        $parameters = [];
        foreach ($subject as $param) {
            if (is_array($param)) {
                $parameters[] = self::replacePatternWithKeyword($param, $keyword, $pattern);
            } else {
                $parameters[] = str_replace($pattern, $keyword, $param);
            }
        }

        return $parameters;
    }
656829
public static function preg_replace_array($pattern, array $replacements, $subject)
    {
        return preg_replace_callback($pattern, function () use (&$replacements) {
            foreach ($replacements as $key => $value) {
                return array_shift($replacements);
            }
        }, $subject);
    }
1330813
public function replaceEnding($search, $replacement)
    {
        return $this->regexReplace
        (
            preg_quote($search, '/').'$',
            UTF8::str_replace('\\', '\\\\', $replacement)
        );
    }
854347
public static String preg_replace(Pattern pattern, String replacement, String subject) {
        Matcher m = pattern.matcher(subject);
        StringBuffer sb = new StringBuffer(subject.length());
        while(m.find()){ 
            m.appendReplacement(sb, replacement);
        }
        m.appendTail(sb);
        return sb.toString();
    }
1019439
public function replace_outside_quotes($search, $replace)
        {
            $this->search = $search;
            $this->replace = $replace;
            return $this->_str_replace_outside_quotes();
        }
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);
    }
100033
function replace($search,$replace){
		$this->_String = str_replace($search,$replace,$this->_String);
	}
223613
public static String preg_replace(String regex, String replacement, String subject) {
        Pattern p = Pattern.compile(regex);
        return preg_replace(p, replacement, subject);
    }
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));
    }
866442
private function replace(
        ColumnMetadata $columnMetadata,
        string $searchTerm,
        string $replaceTerm,
        string $subject
    ): FieldReplaceResult {
        $fieldReplaced = null;
        foreach ($this->replacementStrategyList as $replacementStrategy) {
            if ($replacementStrategy->canReplace($searchTerm, $subject)) {
                $fieldReplaced = $replacementStrategy->replace(
                    $columnMetadata,
                    $searchTerm,
                    $replaceTerm,
                    $subject
                );
                break;
            }
        }

        if (is_null($fieldReplaced)) {
            throw new \RuntimeException('Error trying to replace "' . $searchTerm . '" with "' . $replaceTerm . '"');
        }

        return $fieldReplaced;
    }
892323
function replaceCI($search, $replace, $subject, $count = null) {
		if (!is_array($search)) {
			$slen = mb_strlen($search);
			if (0 === $slen) {
				return $subject;
			}
			$lendif = mb_strlen($replace) - mb_strlen($search);
			$search = mb_strtolower($search);
			$search = preg_quote($search);
			$lstr = mb_strtolower($subject);
			$i = 0;
			$matched = 0;
			/** @var string[] $matches */
			$matches = [];
			while (1 === preg_match('/(.*)'.$search.'/Us',$lstr, $matches)) {
				if ($i === $count ) {
					break;
				}
				$mlen = mb_strlen($matches[0]);
				$lstr = mb_substr($lstr, $mlen);
				$subject =
					substr_replace(
						$subject, $replace, $matched+strlen($matches[1]), $slen
					)
				;
				$matched += $mlen + $lendif;
				$i++;
			}
			return $subject;
		}
		else {
			foreach (array_keys($search) as $k ) {
				if (is_array($replace)) {
					if (array_key_exists($k,$replace)) {
						$subject = $this->replaceCI($search[$k], $replace[$k], $subject, $count);
					}
					else {
						$subject = $this->replaceCI($search[$k], '', $subject, $count);
					}
				} else {
					$subject = $this->replaceCI($search[$k], $replace, $subject, $count);
				}
			}
			return $subject;
		}
	}
848396
private function replaceMatches($type, $pattern, $subject, $responseBody)
    {
        $matches = [];

        $matchCount = preg_match_all(
            $pattern,
            $subject,
            $matches
        );

        if ($matchCount > 0) {
            // we don't need full matches
            unset($matches[0]);
            $responseBody = $this->replaceMatchesInBody($matches, $type, $responseBody);
        }

        return $responseBody;
    }
80621
private function resolveSubject(Subject $part)
    {
        $subject = $part->getSubject();
        foreach ($part->getParameters() as $search => $replace) {
            $subject = str_replace($search, $replace, $subject);
        }

        return $subject;
    }
91625
function match($subject, &$match) {
            if (count($this->_patterns) == 0) {
                return false;
            }
            if (!preg_match($this->_getCompoundedRegex(), $subject, $matches)) {
                $match = "";
                return false;
            }
            $match = $matches[0];
            for ($i = 1; $i < count($matches); $i++) {
                if ($matches[$i]) {
                    return $this->_labels[$i - 1];
                }
            }
            return true;
        }
160941
function replace($search,$replace){
		settype($search,"string");

		// prevod StringBuffer na string
		if(is_object($replace)){
			$replace = $replace->toString();
		}

		for($i=0;$i<sizeof($this->_Buffer);$i++){
			$this->_Buffer[$i]->replace($search,$replace);
		}
	}
1271084
public function _preg_filter($subject, $pattern, $replacement = '', $limit = -1)
    {
        if (!isset($subject)) {
            return;
        } else {
            return preg_filter($pattern, $replacement, $subject, $limit);
        }
    }