File size: 457 Bytes
96f3b64 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import re
_EMOJI_RE = re.compile(
"["
"\U0001F600-\U0001F64F"
"\U0001F300-\U0001F5FF"
"\U0001F680-\U0001F6FF"
"\U0001F1E0-\U0001F1FF"
"\U00002702-\U000027B0"
"\U0000FE00-\U0000FE0F"
"\U0001F900-\U0001F9FF"
"\U0001FA00-\U0001FA6F"
"\U0001FA70-\U0001FAFF"
"\U00002600-\U000026FF"
"\U0000200D"
"]",
flags=re.UNICODE,
)
def count_emojis(text: str) -> int:
return len(_EMOJI_RE.findall(text or ""))
|