Replaces string in buffer with replacement string.

@access public

@param string $search replaced string
@param string|StringBuffer $replace	replacement string. or another StringBuffer object
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);
		}
	}
1358765
public function replaceLast( string $search, string $replace ) : SplString
    {
        $position = strrpos( $this->__toString(), $search );

        if( $position !== false ){
            return $this->setString( substr_replace( $this->__toString(), $replace, $position, strlen( $search ) ) );
        }

        return $this;
    }
1123913
public function replaceSuffix($searchFor, $replaceWith = null) {
		if ($this->endsWith($searchFor)) {
			return $this->replaceLast($searchFor, $replaceWith);
		}
		else {
			return $this;
		}
	}
10970
protected static function strReplaceOnce($search, $replace, $subject)
    {
        $firstChar = strpos($subject, $search);
        if (false !== $firstChar) {
            $beforeStr = substr($subject, 0, $firstChar);
            $afterStr = substr($subject, $firstChar + strlen($search));

            return $beforeStr.$replace.$afterStr;
        }

        return $subject;
    }
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);
    }
724917
function replaceString(content, search, replace) {
        var index = 0;

        do {
          index = content.indexOf(search, index);

          if (index !== -1) {
            content = content.substring(0, index) + replace + content.substr(index + search.length);
            index += replace.length - search.length + 1;
          }
        } while (index !== -1);

        return content;
      }
1065145
public static String replace(String str, String search, String replace) {
        if (str == null || search == null || replace == null) {
            return str;
        }
        StringBuilder sb = new StringBuilder();
        int searchLen = search.length();
        int stringLen = str.length();
        int oldIndex = 0;
        int index;
        while ((index = str.indexOf(search, oldIndex)) >= 0) {
            sb.append(str, oldIndex, index);
            sb.append(replace);
            oldIndex = index + searchLen;
        }
        if (oldIndex < stringLen) {
            sb.append(str, oldIndex, stringLen);
        }
        return sb.toString();
    }
1082217
public function findReplaceRegex(string $find, string $replace)
    {
        $contents = $this->file->getContents();
        $contents = \preg_replace($find, $replace, $contents, -1/*, $count*/);

        $this->file->setContents($contents);
    }
10374
def substitute(search, replace, text):
    ''
    return re.sub(re.compile(str(search)), replace, text)
80961
public function replace($search, $replace, &$count = null)
    {
        $this->string = str_replace($search, $replace, $this->string, $count);

        return $this;
    }
1081671
public static function replace($needle, $replacement, ?string $haystack): ?string
    {
        if ($haystack === null) {
            return null;
        }

        return str_replace($needle, $replacement, $haystack);
    }
336005
public function recursiveReplace($search, $replace)
	{
		$json = json_encode($this->params);

		$json = str_replace($search, $replace, $json);

		$this->params = json_decode($json, TRUE);
	}
89162
public static function replaceLast($search, $replace, $subject)
    {
        $position = mb_strrpos($subject, $search);

        if ($position !== false) {
            return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position + mb_strlen($search));
        }

        return $subject;
    }
144229
public static String replace(String str, String[] search, String[] replace) {
        if (str == null || search == null || replace == null) {
            return str;
        }
        StringBuilder sb = new StringBuilder(str);
        int loop = (search.length <= replace.length) ? search.length : replace.length;
        int start = 0;
        int end;
        int searchLen;
        int replaceLen;
        for (int i = 0; i < loop; i++) {
            if (search[i] == null || replace[i] == null) {
                continue;
            }
            searchLen = search[i].length();
            replaceLen = replace[i].length();
            while (true) {
                if (sb.length() == 0) {
                    break;
                }
                start = sb.indexOf(search[i], start + replaceLen);
                if (start == -1) {
                    break;
                }
                end = start + searchLen;
                sb.replace(start, end, replace[i]);
            }
        }
        return sb.toString();
    }
657771
public function replaceArray( string $search, array $replace ) : SplString
    {
        foreach( $replace as $value ){
            $this->setString( $this->replaceFirst( $search, $value ) );
        }
        return $this;
    }
1257454
public function StrReplace($search = ' ', $replace = '')
    {
        $owner = $this->owner;
        $owner->value = str_replace(
            $search,
            $replace,
            $owner->value
        );
        return $owner;
    }
1349463
public static function replace($search, $replace, $subject)
    {
        foreach ((array)$search as $item) {
            $subject = str_replace($item, $replace, $subject);
        }
        return $subject;
    }