'How to use python3 remove all emojis? (include mobile emojis)
Right now I have a client string consists an emoji "📲", which means Mobile Phone With Arrow. I want to remove it in my text pre-process step so that I can pass it to my NLP model. I tried to use:
def remove_emojis(text: str) -> str:
emojis = re.compile("["
u"\U0001F600-\U0001F64F" # emoticons
u"\U0001F300-\U0001F5FF" # symbols & pictographs
u"\U0001F680-\U0001F6FF" # transport & map symbols
u"\U0001F1E0-\U0001F1FF" # flags (iOS)
u"\U00002500-\U00002BEF" # chinese char
u"\U00002702-\U000027B0"
u"\U00002702-\U000027B0"
u"\U000024C2-\U0001F251"
u"\U0001f926-\U0001f937"
u"\U00010000-\U0010ffff"
u"\u2640-\u2642"
u"\u2600-\u2B55"
u"\u200d"
u"\u23cf"
u"\u23e9"
u"\u231a"
u"\ufe0f" # dingbats
u"\u3030" # flags (iOS)
"]+", flags=re.UNICODE)
return emojis.sub(r'', text)
But it is not working. I think it does not cover this emoji. Is there any way I can remove emojis like this one?
PS: Keeping only English characters does not work for my case cause the client string is not in English.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
