pythonnlpemojiemoticons

python3 extract :) symbol from string


I found all kinds of tools for pasring emoji and emoticons, but none of them are working for extracting a simple ":)" out of a string:

from emot.emo_unicode import UNICODE_EMO, EMOTICONS
":)" in EMOTICONS
>>>False

I've tried using replace to convert all ":)" to ':‑\)' and it still doesn't work. It seems simple, but I cannot find any examples on the interwebs.

Thanks in advance.


Solution

  • import re
    
    s = 'Pull the emoticon :):) out ):'
    (news, count) = re.subn(r'(\s*:\)\s*)', ' ', s)
    # 'Pull the emoticon out ):'
    
    print('new string', news)
    print('count', count)