Regex and unicode Regex and unicode python python

Regex and unicode


Use a subrange of [\u0000-\uFFFF] for what you want.

You can also use the re.UNICODE compile flag. The docs say that if UNICODE is set, \w will match the characters [0-9_] plus whatever is classified as alphanumeric in the Unicode character properties database.

See also http://coding.derkeiler.com/Archive/Python/comp.lang.python/2004-05/2560.html.


Python's re module doesn't support \p{Letter} or \X. However, the new regex implementation on PyPI does.


In Mastering Regular Expressions from Jeffrey Friedl (great book) it is mentioned that you could use \p{Letter} which will match unicode stuff that is considered a letter.