Replaces the first occurrence of the $search text on the $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));
    }
203599
def search(self, value, createIndex=None):
        ''' 
        '''
        if createIndex:
            self._createIndex = createIndex

        self._search = True
        self.filter(QueryExpression({'$text' : {'$search': value}}))
        return self
162680
public static function replaceLast(string $subject, string $search, string $replace, bool $caseSensitive = true): string
    {
        $pos = $caseSensitive ? mb_strrpos($subject, $search) : mb_strripos($subject, $search);
        if ($pos === false) {
            return $subject;
        }

        return substr_replace($subject, $replace, $pos, mb_strlen($search));
    }
1230949
protected function replaceTemplate($search, $replace, &$subject)
    {
        $subject = $this->strReplace($search, $replace, $subject);

        return $this;
    }
139815
function replace(haystack, needle) {
			const replacement = options.resolve ? notate(data, needle.trim()) : data[needle.trim()];

			return VALID_RESULT_TYPES.includes(typeof replacement) ? replacement : options.clean ? '' : haystack;
		}
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());
  }
1159456
protected function strReplace($search, $replace, $subject)
    {
        $template = $this->getTemplateVariable($search);

        return str_replace($template, $replace, $subject);
    }
1171044
public function replaceText($search, $replace)
    {
        if (!$this->open('r+')) {
            return false;
        }

        if ($this->lock !== null && flock($this->handle, LOCK_EX) === false) {
            return false;
        }

        $replaced = $this->write(str_replace($search, $replace, $this->read()), 'w', true);

        if ($this->lock !== null) {
            flock($this->handle, LOCK_UN);
        }
        $this->close();

        return $replaced;
    }
658593
function replaceWithSurround(text, find, prefix, suffix) {
  const escapedString = escapeRegex(find);
  const re = new RegExp(escapedString, 'gi');
  return text.replace(re, matched => prefix + matched + suffix);
}
223126
public static void replace(final StringBuffer sb, final String find, final String replacement) {
		int pos = 0;
		while(pos<sb.length()) {
			pos = sb.indexOf(find, pos);
			if(pos==-1) break;
			sb.replace(pos, pos+find.length(), replacement);
			pos += replacement.length();
		}
	}
609430
function replace(match, text) {
        var rng = rangeFromMatch(match);

        rng.deleteContents();

        if (text.length > 0) {
          rng.insertNode(editor.dom.doc.createTextNode(text));
        }

        return rng;
      }
804698
def replace_first(input, string, replacement = ''.freeze)
      input.to_s.sub(string.to_s, replacement.to_s)
    end
10374
def substitute(search, replace, text):
    ''
    return re.sub(re.compile(str(search)), replace, text)
686344
public function doRegexpReplace($searchPattern, $replaceWith)
    {
        $this->content = preg_replace_callback(
            $searchPattern,
            function($matches) use ($replaceWith) {
                $indent = isset($matches['indent']) ? $matches['indent'] : '';
                $output = $indent;
                $output .= isset($matches['start']) ? $matches['start'] : '';
                $output .= isset($matches['target']) ? Formatter::indentLines($replaceWith, mb_strlen($indent), true) : '';
                $output .= isset($matches['end']) ? $matches['end'] : '';

                return $output;
            },
            $this->content
        );

        return $this;
    }
891541
private function replaceBasic($searchFor, $replaceWith)
    {
        if ($this->isPrefixUsed()) {
            $searchFor = $this->globalPrefix . $searchFor;
        }

        $this->doReplace($searchFor, $replaceWith);
    }
1055057
public function replace($search, $replace): NamespaceDeclaration
    {
        $this->docComment->replace($search, $replace);
        $this->elements->replace($search, $replace);

        return $this;
    }
1107575
public function replace($search, $replace): Method
    {
        $this->docComment->replace($search, $replace);

        return $this;
    }