backslash in regular expression problem

Andrew Kuchling akuchlin at mems-exchange.org
Wed Jun 28 12:46:48 EDT 2000


Gordon McLeod <Gordon.McLeod at wolfson.co.uk> writes:
> I am trying to follow the advice of the Python Library Reference Manual,
> section 4.3 which says:
> 
>      However, if you want to include a literal backslash in a
>      regular expression represented as a string literal, you have
>      to quadruple it or enclose it in a singleton character class.

I think the manual is simply wrong on this point; try
re.compile(r'[\\]').

--amk



More information about the Python-list mailing list