-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[String] Add a method to strip emojis from strings #48850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How's the result in your example ( |
@derrabus sorry! It was a copy+paste mistake. I've just updated the above example. |
Thanks. Makes much more sense now. π |
You can use the EmojiTransliterator for that. |
I agree a shortcut method would still be useful, something like: public function stripEmojis(): static
{
if (null === (self::$transliterators['emoji-strip'] ?? null)) {
if (!class_exists(EmojiTransliterator::class)) {
throw new \LogicException(sprintf('You cannot use the "%s()" method as the "symfony/intl" package is not installed. Try running "composer require symfony/intl".', __METHOD__));
}
self::$transliterators['emoji-strip'] = EmojiTransliterator::create('emoji-strip');
}
$str = clone $this;
$str->string = self::$transliterators['emoji-strip']->transliterate($str->string);
return $str;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
In #48396 we added an option to remove emojis from slugs:
I'd like to have this feature for strings too, not only slugs.
Example
The text was updated successfully, but these errors were encountered: