carpedm20 / emoji

emoji terminal output for Python
Other
1.9k stars 278 forks source link

Detection of multiple emojis without separating spaces #206

Closed tbuz closed 2 years ago

tbuz commented 2 years ago

Currently, emoji.is_emoji() does not return True when the input contains multiple emojis without spaces in between, e.g.

print(is_emoji("🚀"))
# True

print(is_emoji("🚀🚀🚀"))
# False

Is this intended or could it be added to the package?

cvzi commented 2 years ago

I'd say it is the intended behavior

There is emoji_lis() which returns all emoji in a string:

print(emoji.emoji_lis("🚀🚀🚀"))
# [{'location': 0, 'emoji': '🚀'}, {'location': 1, 'emoji': '🚀'}, {'location': 2, 'emoji': '🚀'}]

# note that emoji can span multiple chars:
print(emoji.emoji_lis("👨‍🎤🚀🚀"))
# [{'location': 0, 'emoji': '👨‍🎤'}, {'location': 3, 'emoji': '🚀'}, {'location': 4, 'emoji': '🚀'}]

# in version 1.7.0 there is also:
print(emoji.emoji_list("👨‍🎤🚀🚀"))
# [{'match_start': 0, 'match_end': 3, 'emoji': '👨‍🎤'}, {'match_start': 3, 'match_end': 4, 'emoji': '🚀'}, {'match_start': 4, 'match_end': 5, 'emoji': '🚀'}]