[Python-Dev] recognizing \u escapes in regular expressions

Guido van Rossum guido@digicool.com
Fri, 15 Jun 2001 12:59:40 -0400


> during a late hacking pass, I was perplexed to realized that
> r"[\u0000-\uffff]" didn't match any unicode character, and reported
> it as bug #420011.
> 
> but a few minutes later, I realized that SRE doesn't support \u and
> \U escapes at all -- and that the pattern u"[\u0000-\uffff]" works
> as expected.
> 
> should I close the bug report, or turn it into a feature request?
> 
> </F>

You meant ur"[\u0000-\uffff]", right?  (It works the same -- Unicode
raw strings still do \u expansion, although the rationale escapes me
at the moment -- as does the rationale for why ru"..." is a syntax
error...)

Looks like a feature request to me.  Since \000 and \x00 work in that
context, \u0000 would be expected to work.  And suppose someone uses
u"[\u0000-\u005d]"...

--Guido van Rossum (home page: http://www.python.org/~guido/)