Emoji (Unicode) in PY
Match emoji characters across the main Unicode emoji ranges — requires the Unicode flag in JavaScript.
Try it in the PY tester →Pattern
regexPY
[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{FE00}-\u{FEFF}\u{1F000}-\u{1F02F}\u{1FA00}-\u{1FA9F}] (flags: gu)Python (re) code
pyPython
import re
pattern = re.compile(r"[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{FE00}-\u{FEFF}\u{1F000}-\u{1F02F}\u{1FA00}-\u{1FA9F}]")
input_text = "Hello 🌍 World 🎉"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
How the pattern works
The character class covers the primary emoji Unicode blocks: Miscellaneous Symbols and Pictographs (1F300–1F9FF), Misc Symbols (2600–26FF), Dingbats (2700–27BF), Variation Selectors (FE00–FEFF), Mahjong/playing cards (1F000–1F02F), and Supplemental Symbols (1FA00–1FA9F). The u flag in JavaScript is required to interpret \u{XXXXX} code points above 0xFFFF. In Python, use re.UNICODE (default in Python 3). In Go RE2, use \x{XXXXX} syntax instead of \u{XXXXX}.
Examples
Input
Hello 🌍 World 🎉Matches
🌍🎉
Input
⚡ Fast ☁ Cloud ⭐ StarMatches
⚡☁⭐
Input
plain text onlyNo match
—