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

M.-A. Lemburg mal@lemburg.com
Sat, 16 Jun 2001 20:59:52 +0200


"Martin v. Loewis" wrote:
> 
> > should I close the bug report, or turn it into a feature request?
> 
> I think the bug report can be closed. Myself, I found it sufficient
> that you can write normal \u escapes in strings, in particular as you
> can also use them in raw strings:
> 
> >>> ur"Ha\u006Clo"
> u'Hallo'
> 
> Perhaps not very intuitive, and perhaps even a bug (how do you put a
> backslash in front of a "u" in a raw unicode string), but useful in
> this context.

>>> print ur"backslash in front of an 'u': \u005cu"
backslash in front of an 'u': \u

A double backslash is easier to have:
>>> print ur"double backslash in front of an 'u': \\u"
double backslash in front of an 'u': \\u

Python uses C's convention for \uXXXX where \u is only
interpreted as Unicode escape of it is used with an odd
number of backslashes in front of it.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/