Create a slug by converting and removing all non-ascii characters.

@param string $text

@return string
963959
public function slugify(string $text): string
    {
        $map = $this->getMap();
        $text = str_replace(array_keys($map), array_values($map), trim($text));

        $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII; Lower()');

        $text = $transliterator->transliterate($text);
        $text = str_replace('&', 'and', $text);

        return preg_replace(
            ['/[^\w\s]/', '/\s+/'],
            ['', '-'],
            $text
        );
    }
929300
public static function slug($title)
    {
        foreach (static::charsArray() as $key => $value) {
            $title = str_replace($value, $key, $title);
        }

        $title = preg_replace('/[^\x20-\x7E]/u', '', $title);

        $separator = '_';
        // Convert all dashes into underscores
        $title = preg_replace('![' . preg_quote('-') . ']+!u', $separator, $title);

        // Remove all characters that are not the separator, letters, numbers, or whitespace.
        $title = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', $title);

        // Replace all separator characters and whitespace by a single separator
        $title = preg_replace('![' . preg_quote($separator) . '\s]+!u', $separator, $title);

        return trim($title, $separator);
    }
640180
public function make(string $text): string
    {
        $map = $this->getMap();
        $transliterated = str_replace(array_keys($map), array_values($map), $text);

        if (true === config('transliterate.remove_accents', false)) {
            $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII');
            $transliterated = $transliterator->transliterate($transliterated);
        }

        return self::applyTransformers($transliterated);
    }
67267
public function toMorse($text) {
        $text = strtoupper($text);
        $words = preg_split('#\s+#', $text);
        $morse = array_map([$this, 'morseWord'], $words);
        return implode($this->wordSeparator, $morse);
    }
1060975
public static function toCamelCaseFormat($text, $separator = '-')
    {
        $slugified = self::urlize($text, $separator);
        $camel = strtolower($slugified);
        $camel = ucwords($camel, $separator);

        return str_replace($separator, '', $camel);
    }
1273267
public function slug($text) {
		$table = [
			'Š'=>'S', 'š'=>'s', 'Đ'=>'Dj', 'đ'=>'dj', 'Ž'=>'Z', 'ž'=>'z', 'Č'=>'C', 'č'=>'c', 'Ć'=>'C', 'ć'=>'c',
			'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'AE', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
			'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O',
			'Õ'=>'O', 'Ö'=>'OE', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'UE', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'ss',
			'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e',
			'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o',
			'ô'=>'o', 'õ'=>'o', 'ö'=>'oe', 'ø'=>'o', 'ü'=>'ue', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b',
			'ÿ'=>'y', 'Ŕ'=>'R', 'ŕ'=>'r',
		];

		$slug = strtr($text, $table);
		$slug = trim(preg_replace("|\W+|", '-', $slug), '-');
		return $slug;
	}
1289491
public static function cleanText(string $text)
    {
        $text = preg_replace('/<script[^>]*>.*?</script>/si', '', $text);
        $text = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $text);
        $text = preg_replace('/<!--.+?-->/', '', $text);
        $text = preg_replace('/{.+?}/', '', $text);
        $text = preg_replace('/&nbsp;/', ' ', $text);
        $text = preg_replace('/&amp;/', ' ', $text);
        $text = preg_replace('/&quot;/', ' ', $text);
        $text = strip_tags($text);
        $text = htmlspecialchars($text);

        return $text;
    }
105078
public function normalizeText( $text )
    {
        if ( $this->searchHandler instanceof LegacyHandler )
        {
            $searchEngine = new eZSearchEngine();
            return $searchEngine->normalizeText( $text );
        }

        return $text;
    }
688728
public static function slugify($string) {
        $string = strip_tags($string);
        $string = str_replace(['&amp;', '&'], 'and', $string);
        $string = str_replace('@', 'at', $string);

        // @codeCoverageIgnoreStart
        if (class_exists('Titon\G11n\Utility\Inflector')) {
            return \Titon\G11n\Utility\Inflector::slug($string);
        }
        // @codeCoverageIgnoreEnd

        return Inflector::slug($string);
    }
518189
public function purge($text)
    {
        if (!$matches = $this->getMatches($text)) {
            return $text;
        }

        return str_replace($matches, '', $text);
    }
1240480
public function slugify($text)
    {
        $text = $this->slugifier->slugify($text);

        // jackrabbit can not handle node-names which contains a number followed by "e" e.g. 10e
        $text = preg_replace('((\d+)([eE]))', '$1-$2', $text);

        return $text;
    }
1310217
private function getTranslatedText($text)
    {
        if ($this->isEnglish($text)) {
            return $text;
        }
        $text = $this->removeSegment($text);
        $url = $this->getTranslateUrl($text);
        $response = $this->http->get($url);

        return $this->getTranslation(json_decode($response->getBody(), true));
    }
750001
public function initialLetter(string $text): string
    {
        $text = I18N::strtoupper($text);

        $digraphs = self::DIGRAPHS[$this->locale->languageTag()] ?? [];

        foreach ($digraphs as $key => $value) {
            if (substr_compare($text, $key, 0, strlen($key)) === 0) {
                return $value;
            }
        }

        // No special rules - just take the first character
        return mb_substr($text, 0, 1);
    }
112367
public static function ampReplace($text)
    {
        $text = str_replace('&&', '*--*', $text);
        $text = str_replace('&#', '*-*', $text);
        $text = str_replace('&amp;', '&', $text);
        $text = preg_replace('|&(?![\w]+;)|', '&amp;', $text);
        $text = str_replace('*-*', '&#', $text);
        $text = str_replace('*--*', '&&', $text);

        return $text;
    }
676297
protected function cleanText($text)
    {
        $strippedText = strip_tags($text);
        $strippedText = htmlentities($strippedText, ENT_QUOTES, $this->getCharset(), FALSE);
        return html_entity_decode($strippedText, ENT_QUOTES, $this->getCharset());
    }
513255
public function asText($text)
    {
        $stream = StreamFactory::string($text);
        return new Response($stream, self::OK, ['Content-Type' => 'text/plain']);
    }
1276882
public static function cleanText(&$text)
    {
        $text = preg_replace("'<script[^>]*>.*?</script>'si", '', $text);
        $text = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $text);
        $text = preg_replace('/<!--.+?-->/', '', $text);
        $text = preg_replace('/{.+?}/', '', $text);
        $text = preg_replace('/&nbsp;/', ' ', $text);
        $text = preg_replace('/&amp;/', ' ', $text);
        $text = preg_replace('/&quot;/', ' ', $text);
        $text = strip_tags($text);
        $text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');

        return $text;
    }