Skip to content

Instantly share code, notes, and snippets.

@talhasch
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talhasch/0bae3e2f5e57a4ff3035 to your computer and use it in GitHub Desktop.
Save talhasch/0bae3e2f5e57a4ff3035 to your computer and use it in GitHub Desktop.
python function that removes emojis from text
def clean_emoji(text):
import re
try:
# Wide UCS-4 build
emoji_re = re.compile(u'['
u'\U0001F300-\U0001F64F'
u'\U0001F680-\U0001F6FF'
u'\u2600-\u26FF\u2700-\u27BF]+',
re.UNICODE)
except re.error:
# Narrow UCS-2 build
emoji_re = re.compile(u'('
u'\ud83c[\udf00-\udfff]|'
u'\ud83d[\udc00-\ude4f\ude80-\udeff]|'
u'[\u2600-\u26FF\u2700-\u27BF])+',
re.UNICODE)
text = emoji_re.sub(u'', text)
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment