Issue
Consider the following list:
a_list = ['🤔 🙈 me asÃ, bla es se 😌 ds 💕ðŸ‘👙']
How can I extract in a new list all the emojis inside a_list
?:
new_lis = ['🤔 🙈 😌 💕 👠👙']
I tried to use regex, but I do not have all the possible emojis encodings.
Solution
You can use the emoji
library. You can check if a single codepoint is an emoji codepoint by checking if it is contained in emoji.UNICODE_EMOJI
.
import emoji
def extract_emojis(s):
return ''.join(c for c in s if c in emoji.UNICODE_EMOJI['en'])
Answered By - Pedro Castilho
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.