No explanation for weird behavior in re module!

Sean 'Shaleh' Perry shalehperry at attbi.com
Sun Feb 10 19:14:58 EST 2002


On 11-Feb-2002 synthespian wrote:
> Hi-
> 
>       I'm really intrigued by this behavior:
> 
>>>> import re
>>>> p = re.compile('^(der|die|das(\s\w+))')

The \w symbol makes decisions based on your locale.  So, set LC_ALL=de_DE and
umlauts should work.  This assumes you have the german locale installed (under
Debian it is /etc/locale.gen which decides this).  More info on \w can be found
in the re module docs.

sre is simply the faster implementation of re, you are probably using it unless
you force python not to do so.




More information about the Python-list mailing list