I used this post to make a regex that would find emojis in a string of text and simply stick some space characters on either side. my regex code:
try:
# Wide UCS-4 build
oRes = re.compile(u'['
u'\U0001F300-\U0001F64F'
u'\U0001F680-\U0001F6FF'
u'\u2600-\u26FF\u2700-\u27BF]+',
re.UNICODE)
except re.error:
# Narrow UCS-2 build
oRes = re.compile(u'('
u'\ud83c[\udf00-\udfff]|'
u'\ud83d[\udc00-\ude4f\ude80-\udeff]|'
u'[\u2600-\u26FF\u2700-\u27BF])+',
re.UNICODE)
s2 = oRE.sub(r' \1 ', s1)
However, I am getting some really odd behaviour where emojis are being removed, as in the example below. Any advice would be appreciated. I am using Python on a MacBook. Thanks.
INPUT
هيلاري كلينتون "متنحة" وتشير إلى عملية غش في ولاية بانسيلفانيا العتيقة قائلة: "عند فرز الاصوات ..قطعوا الكهربا ✋" #ابو_الياس
OUTPUT
هيلاري كلينتون "متنحة" وتشير إلى عملية غش في ولاية بانسيلفانيا العتيقة قائلة: "عند فرز الاصوات ..قطعوا الكهربا ✋ " #ابو_الياس