Removing emoji from text remove also Japanese language

╄→尐↘猪︶ㄣ 提交于 2020-01-06 12:46:52

问题


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:


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



来源:https://stackoverflow.com/questions/52464119/removing-emoji-from-text-remove-also-japanese-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!