Eliminate a duplicate given phrase from a given string

@param string $subject
@param string $eliminate

@return string
768965
public static function eliminateDupilcates($subject, $eliminate = "\\")
    {
        $pattern = $eliminate . $eliminate;

        while (strpos($subject, $pattern) !== false) {
            $subject = str_replace($pattern, $eliminate, $subject);
        }

        return $subject;
    }
1123614
public function replace($pattern, $replacement , $subject, $limit = -1, &$count = null)
    {
        return $this->sandbox->run('preg_replace', func_get_args(), $this->throw);
    }
825024
public function match(string $subject, $flags = 0, $offset = 0): int
	{
		$this->clean();
		return preg_match($this->pattern, $subject, $this->last_match, $flags, $offset);
	}
635287
public static function all($pattern, $subject, Results\PregObject $object = null): Results\PregObject
    {
        $object = static::pregObject($object);

        $object->flags  = null === $object->flags ? $object->flags : PREG_PATTERN_ORDER;
        $object->result = \preg_match_all(
            $pattern,
            $subject,
            $object->matches,
            $object->flags,
            $object->offset
        );

        return $object;
    }
187121
public function injectMessageReplacements($message, $subject, $substitutions) {
		// Handle empty messages
		if(empty($subject) && empty($message)) return array(null, null);

		// Check if there's a role specific message
		$subjectText = str_replace(
			array_keys($substitutions),
			array_values($substitutions),
			$subject ?: $message
		);
		$messageText = str_replace(
			array_keys($substitutions),
			array_values($substitutions),
			$message ?: $subject
		);
		return array($subjectText, $messageText);
	}
856649
public function plainText($subject) : bool
    {
        if ($subject === null) {
            return false;
        }
        $v = '' . $subject;
        return $v === '' ? true : !strcmp($v, strip_tags($v));
    }
61213
public static function split(string $subject, string $pattern, int $flags = 0): array
    {
        return static::pcre('\preg_split', [$pattern, $subject, -1, $flags | PREG_SPLIT_DELIM_CAPTURE]);
    }
759728
public static function removeFirst(string $subject, string $search, bool $caseSensitive = true): string
    {
        return static::replaceFirst($subject, $search, '', $caseSensitive);
    }
222267
public static function replaceString($from, $to, $subject, $limit = 100000)
    {
        $from = '/' . preg_quote($from, '/') . '/';
        return preg_replace($from, $to, $subject, $limit);
    }
859856
private function matches($pattern, $subject)
    {
        if (preg_match($pattern, $subject, $matches)) {
            $args = array();

            foreach ($matches as $key => $value) {
                if (!is_int($key)) {
                    $args[$key] = $value;
                }
            }

            return $args;
        }

        return false;
    }
500405
public function match($pattern, $subject)
    {
        if (! $this->validate($pattern)) {
            return false;
        }
        
        return $this->getInstance()->match($pattern, $subject);
    }
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;
		}
	}
471167
private function translateSubject($subject, array $subjectParams)
    {
        foreach ($subjectParams as &$param) {
            $param = $this->translator->trans($param);
        }

        unset($param);

        return $this->translator->trans($subject, $subjectParams);
    }
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();
    }
554485
public static function Match ($pattern, $subject, array &$matches = array(), $flags = 0, $offset = 0, $from_encoding = Encoding::DEFAULT_ENCODING) {
		return Regex::match($pattern, $subject, $matches, $flags, $offset, $from_encoding);
	}
363986
public function replace($replacement, $subject, $seed = '')
	{
		if (!empty($seed))
		{
			$this->addSeed($seed);
		}

		return preg_replace($this->compile(), $replacement, $subject);
	}
460850
public static function first($pattern, $subject, Results\PregObject $object = null): Results\PregObject
    {
        $object = static::pregObject($object);

        $object->result = \preg_match(
            $pattern,
            $subject,
            $object->matches,
            $object->flags,
            $object->offset
        );

        return $object;
    }