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.
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)