Performs search and replacement on the specified database and table.

@param string $databaseName
@param string $tableName
@param string $searchTerm
@param string $replaceTerm
@return \Generator|RowReplaceResult[]
195619
public function replaceTable(
        string $databaseName,
        string $tableName,
        string $searchTerm,
        string $replaceTerm
    ): \Generator {
        return $this->replace->replaceTable(
            $this->connection,
            $databaseName,
            $tableName,
            $searchTerm,
            $replaceTerm
        );
    }
401143
public static function last_replace($search, $replace, $string)
    {
        $pos = strrpos($string, $search);
        
        if($pos !== false)
        {
            return substr_replace($string, $replace, $pos, strlen($search));
        }
        else
        {
            return $string;
        }
    }
1370732
public static function strIreplace($search, $replace, $str, $count = null, $encoding = null)
    {
        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        if (!is_array($search)) {
            $slen = strlen($search);

            if ($slen == 0) {
                return $str;
            }

            $lendif = strlen($replace) - strlen($search);
            $search = static::strtolower($search, $encoding);
            $search = preg_quote($search, '/');
            $lstr = static::strtolower($str, $encoding);
            $i = 0;
            $matched = 0;

            while (preg_match('/(.*)' . $search . '/Us', $lstr, $matches)) {
                if ($count !== null && $i === $count) {
                    break;
                }

                $mlen = strlen($matches[0]);
                $lstr = substr($lstr, $mlen);

                $str = substr_replace($str, $replace, $matched + strlen($matches[1]), $slen);
                $matched += $mlen + $lendif;
                $i++;
            }

            return $str;
        } else {
            $keys = array_keys($search);

            foreach ($keys as $k) {
                if (is_array($replace)) {
                    if (array_key_exists($k, $replace)) {
                        $str = static::strIreplace($search[$k], $replace[$k], $str, $count, $encoding);
                    } else {
                        $str = static::strIreplace($search[$k], '', $str, $count, $encoding);
                    }
                } else {
                    $str = static::strIreplace($search[$k], $replace, $str, $count, $encoding);
                }
            }

            return $str;
        }
    }
1254027
public function replace($table, array $columns = null, array $where = null): ?array
    {
        if (\is_array($table)) {
            $columns = $this->getColumns($table, false);
            $table = $this->getTable($table);
            $where = $table;
        } elseif ($where) {
            $where = [SQL::WHERE => $where];
        }

        if (!\is_array($columns) || empty($columns)) {
            return null;
        }

        $map = [];
        $stack = [];

        foreach ($columns as $column => $replacements) {
            if (\is_array($replacements)) {
                foreach ($replacements as $old => $new) {
                    $mapKey = $this->mapKey();

                    $stack[] = $this->columnQuote($column) . ' = REPLACE(' . $this->columnQuote($column) . ', ' . $mapKey . 'a, ' . $mapKey . 'b)';

                    $map[$mapKey . 'a'] = [$old, PDO::PARAM_STR];
                    $map[$mapKey . 'b'] = [$new, PDO::PARAM_STR];
                }
            }
        }

        if ($stack === []) {
            return null;
        }

        $sql = 'UPDATE ' . $this->tableQuote($table) . ' SET ' .
            \implode(', ', $stack) . $this->suffixClause($where, $map);

        return [$sql, $map];
    }
47440
public static function replace($search, $replace, $string, $caseSensitive = true)
    {
        if (!self::isValid($replace)) {
            return false;
        }

        if (!$caseSensitive) {
            return str_ireplace($search, $replace, $string);
        } else {
            return str_replace($search, $replace, $string);
        }
    }
1182027
public function replaceBeginning($search, $replacement)
    {
        return $this->regexReplace
        (
            '^'.preg_quote($search, '/'),
            UTF8::str_replace('\\', '\\\\', $replacement)
        );
    }
881806
public function replaceOneValue($search, $replacement = ''): self
    {
        $array = $this->getArray();
        $key = \array_search($search, $array, true);

        if ($key !== false) {
            $array[$key] = $replacement;
        }

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
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;
    }
807986
protected function getDatabaseSchemata(string $dbName): array
    {
        $sql = 'SELECT
            default_character_set_name,
            default_collation_name
            FROM information_schema.SCHEMATA
            WHERE schema_name = %s;';
        $sql = sprintf($sql, $this->quote($dbName));
        $row = $this->createQueryStatement($sql)->fetch();

        return $row;
    }
1055328
@SuppressWarnings("unchecked")
    private IDataSet performReplacements(IDataSet dataSet) {
        if (!dbUnitConfig.getProperties().containsKey("replacers")) {
            return dataSet;
        }
        return performReplacements(dataSet, (List<Replacer>) dbUnitConfig.getProperties().get("replacers"));
    }
1348935
function replace($search,$replace){
		$this->_String = $this->toString();
		return parent::replace($search,$replace);
	}
744604
protected function recursiveReplace($base, $replacement)
    {
        $replace_values_recursive = function (array $array, array $order) use (&$replace_values_recursive) {
            $array = array_replace($order, array_replace($array, $order));

            foreach ($array as $key => &$value) {
                if (is_array($value)) {
                    $value = (array_key_exists($key, $order) && is_array($order[$key]))
                        ? $replace_values_recursive($value, $order[$key])
                        : $value
                    ;
                }
            }
            return $array;
        };

        return $replace_values_recursive($base, $replacement);
    }
496811
protected function replaceLastOne($search, $replace, $subject, $encoding, &$count, &$offset = null, $lenSearch = null)
	{
		$target = mb_substr($subject, 0, $offset, $encoding);
		$position = mb_strrpos($target, $search, 0, $encoding);

		if ($position === false){
			$offset = false;
			return $subject;
		}

		$lenSearch = is_null($lenSearch) ? mb_strlen($search, $encoding) : $lenSearch;

		$start = mb_substr($subject, 0, $position, $encoding);
		$end = $replace.mb_substr($subject, $position+$lenSearch, null, $encoding);

		$offset = -mb_strlen($end, $encoding);
		++$count;

		return $start.$end;
	}
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);
		}
	}
509124
protected function renameQuery (Query $query, $tableName = null, $columnNames = null) {
        $originalSource = $this->renameSource($query, $tableName);

        if($columnNames == null) {
            $columnNames = $this->getColumnNames();
        }

        if ($query instanceof SelectQuery) {
            $hasFieldMappings = $this->hasFieldMappings($columnNames);
            if (!empty($columnNames)) {
                //si $hasFieldMappings == false llamo igual para el caso de select * que complete solo son lo indicado en columnNames
                $this->renameSelectFields($query, $columnNames, $originalSource);

                if ($hasFieldMappings) {
                    if ($query->hasWhereConditions()) {
                        $this->renameConditionFields($query->getWhereConditionGroup(), $columnNames, $originalSource, $query->getTable());
                    }

                    $this->renameOrderByFields($query, $columnNames, $originalSource);
                    $this->renameGroupByFields($query, $columnNames, $originalSource);
                    $this->renameJoinFields($query, $columnNames, $originalSource);
                }
            }
        }
        else if ($query instanceof UpdateQuery) {
            $hasFieldMappings = $this->hasFieldMappings($columnNames);
            if ($hasFieldMappings) {
                if ($query->hasWhereConditions()) {
                    $this->renameConditionFields($query->getWhereConditionGroup(), $columnNames, $originalSource, $query->getTable());
                }
                $this->renameSetFields($query, $columnNames, $originalSource, $query->getTable());
            }
        }
        else if ($query instanceof InsertQuery) {
            $hasFieldMappings = $this->hasFieldMappings($columnNames);
            if ($hasFieldMappings) {
                $this->renameSetFields($query, $columnNames, $originalSource, $query->getTable());
            }
        }
        else if ($query instanceof DeleteQuery) {
            $hasFieldMappings = $this->hasFieldMappings($columnNames);
            if ($hasFieldMappings) {
                if ($query->hasWhereConditions()) {
                    $this->renameConditionFields($query->getWhereConditionGroup(), $columnNames, $originalSource, $query->getTable());
                }
            }
        }
    }
773986
public function replace($data = null): IResult
    {
        $builder = new ReplaceBuilder($this);
        $sql = $builder->build($data);
        return $this->execute($sql);
    }
1132906
public function replaceValues($search, $replacement = ''): self
    {
        $array = $this->each(
            static function ($value) use ($search, $replacement) {
                return \str_replace($search, $replacement, $value);
            }
        );

        return $array;
    }