Skip to content

Instantly share code, notes, and snippets.

@weallwegot
Last active August 22, 2018 12:52
Show Gist options
  • Save weallwegot/b9c2d0e1a7f28e3dc0a54e42ce849964 to your computer and use it in GitHub Desktop.
Save weallwegot/b9c2d0e1a7f28e3dc0a54e42ce849964 to your computer and use it in GitHub Desktop.
Detecting emoji presence in raw text with regular expressions.
import re
all_text = "πŸ’πŸΎπŸ’πŸΎπŸ’πŸΎπŸ’ πŸ€— 😩😩😩"
txt_utf_8 = all_text.decode('utf-8')
re.findall(ur'(\ud838[\udc50-\udfff])|([\ud839-\ud83d][\udc00-\udfff])|\
(\ud83e[\udc00-\udfbf])|([\udc50-\udfff]\ud838)|\
([\udc00-\udfff][\ud839-\ud83d])|([\udc00-\udfbf]\ud83e)'\
,txt_utf_8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment