Replace

@param string $find
@param string $replace
@param bool   $caseSensitive
@return object|Manipulator
540512
public function replace(string $find, string $replace = '', bool $caseSensitive = true) : Manipulator
    {
        $replaced = $caseSensitive ? str_replace($find, $replace, $this->string) :
                                     str_ireplace($find, $replace, $this->string);

        return new static($replaced);
    }
100033
function replace($search,$replace){
		$this->_String = str_replace($search,$replace,$this->_String);
	}
1374757
private String stringReplace(final String source, final String find, final String replace) {
    if (source == null || find == null || replace == null)
      return source;
    final int index = source.indexOf(find);
    if (index == -1)
      return source; // no occurence, don't do anything;
    if (index == 0)
      return replace + source.substring(find.length());
    return source.substring(0, index) + replace + source.substring(index + find.length());
  }
458561
public function replace($search, $replace, $caseSensitivity = TRUE)
  {
    if($caseSensitivity)
    {
      $this->string = str_replace($search, $replace, $this->string);
    }
    else
    {
      $this->string = str_ireplace($search, $replace, $this->string);
    }

    return $this;
  }
1293138
public function findReplace(string $find, string $replace)
    {
        $contents = $this->file->getContents();
        $contents = \str_replace($find, $replace, $contents);
        $this->file->setContents($contents);

        return $this;
    }
871733
public static function replaceStrict(array $source, array ...$replace) {

        $replacements = [];

        foreach ($replace as $items) {
            $replacements[] = array_intersect_key($items, $source);
        }

        return array_merge($source, ...$replacements);

    }
451545
public static function massStrReplaceFile(string $find, string $replace, string $path)
    {
        $dir = opendir($path);
        while (false !== ($file = readdir($dir))) {
            if (($file != '.') && ($file != '..')) {
                if (is_dir($path . '/' . $file)) {
                    static::massStrReplaceFile($find, $replace, $path . '/' . $file);
                } else {
                    static::strReplaceFile($find, $replace, $path . '/' . $file);
                }
            }
        }
        closedir($dir);
    }
1123614
public function replace($pattern, $replacement , $subject, $limit = -1, &$count = null)
    {
        return $this->sandbox->run('preg_replace', func_get_args(), $this->throw);
    }
97937
public function findReplace(
        string $find,
        string $replace,
        string $filePath
    ): self {
        $contents = \ts\file_get_contents($filePath);
        $contents = str_replace($find, $replace, $contents);
        file_put_contents($filePath, $contents);

        return $this;
    }
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));
    }
917241
public function replace($pattern, $replacement, $flags = 0)
    {

        if ($flags & self::REGEXP) {
            return $this->regexplace($pattern, $replacement);
        } else {
            $function = ($flags & self::CASE_SENSITIVE) ? 'str_replace' : 'str_ireplace';
            $result   = $function($pattern, $replacement, $this->getInternalValue());

        }
        $this->setInternalValue($result);

        return $this;
    }
1123913
public function replaceSuffix($searchFor, $replaceWith = null) {
		if ($this->endsWith($searchFor)) {
			return $this->replaceLast($searchFor, $replaceWith);
		}
		else {
			return $this;
		}
	}
1366574
public function replace($find, $replace)
        {
            $string = $this->get();
            $value = str_replace($find, $replace, $string);
            $this->update($value);
            return $this;
        }
849810
public function replace( $find , $replace = null )
	{
		if ( is_array( $find ) )
			$this->buffer = strtr( $this->buffer , $find );
		else
			$this->buffer = str_replace( $find , $replace , $this->buffer );

		return $this;
	}
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;
    }
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;
		}
	}
1257454
public function StrReplace($search = ' ', $replace = '')
    {
        $owner = $this->owner;
        $owner->value = str_replace(
            $search,
            $replace,
            $owner->value
        );
        return $owner;
    }