First of all you need to install this:
conda install -c conda-forge emoji
Now we can write the following code:
import emoji
import re
text= 'π€ π me asΓ, bla es se π ds πππ'
text_de= emoji.demojize(text)
If we print text_de Output is:
':thinking_face: :see-no-evil_monkey: me asΓ, bla es se :relieved_face: ds
:two_hearts::two_women_holding_hands::bikini:'
Now we can use regex to find emojis.
emojis_list_de= re.findall(r'(:[!_\-\w]+:)', text_de)
list_emoji= [emoji.emojize(x) for x in emojis_list_de]
If we print lis_emoji, output:
['π€', 'π', 'π', 'π', 'π', 'π']
So, we can use Join function:
[''.join(list_emoji)]
OutPut: ['π€πππππ']
If you want to remove emojis you can use following code:
def remove_emoji(text):
'''
remove all of emojis from text
-------------------------
'''
text= emoji.demojize(text)
text= re.sub(r'(:[!_\-\w]+:)', '', text)
return text