John Rauser John Rauser - 3 months ago 12
Python Question

A python regex that matches the regional indicator character class

Flags in emoji are indicated by a pair of Regional Indicator Symbols. I would like to write a python regex to insert spaces between a string of emoji flags.

For example, this string is two Brazilian flags:

u"\U0001F1E7\U0001F1F7\U0001F1E7\U0001F1F7"


Which will render like this:

Answer

I believe you're using Python 2.7 in Windows or Mac, which has the narrow 16-bit Unicode build - Linux/Glibc usually have 32-bit full unicode, also Python 3.5 has wide Unicode on all platforms.

What you see is the one code being split into a surrogate pair. Unfortunately it also means that you cannot use a single character class easily for this task. However it is still possible. The UTF-16 representation of U+1F1E6 (

Comments