0
votes

I use the follow code:

import re

def replace_emoji_space(string):
    emoji_pattern = re.compile("["
                       u"\U0001F600-\U0001F64F"  # emoticons
                       u"\U0001F300-\U0001F5FF"  # symbols & pictographs
                       u"\U0001F680-\U0001F6FF"  # transport & map symbols
                       u"\U0001F1E0-\U0001F1FF"  # flags (iOS)
                       u"\U00002702-\U000027B0"
                       u"\U000024C2-\U0001F251"
                       "]+", flags=re.UNICODE)
    return emoji_pattern.sub(r' ', string)

While string == '趣味でバルーンひねってます' the results is just an empty string, why ?

This is what I get in pycharm: string in pyhon

1
I think it is because the string you are comparing isn't encoded as 'utf-8' - Atul Shanbhag
Are sure you decode your input to utf16? - Léopold Houdin
I am working in python3 isn't every string is a unicode8 ? - Sion Cohen

1 Answers

0
votes
import re

def replace_emoji_space(string):
    emoji_pattern = re.compile("["
                       u"\U0001F600-\U0001F64F"  # emoticons
                       u"\U0001F300-\U0001F5FF"  # symbols & pictographs
                       u"\U0001F680-\U0001F6FF"  # transport & map symbols
                       u"\U0001F1E0-\U0001F1FF"  # flags (iOS)
                       "]+", flags=re.UNICODE)
    return emoji_pattern.sub(r' ', string)

The last 2 removed the japanese