Problem with regular expression
jon+python-list at unequivocal.co.uk
Wed Sep 27 14:31:44 CEST 2000
Pieter Claerhout <Pieter_Claerhout at CreoScitex.com> wrote:
> Looks a bit unlogical to me. The rules say that you either need to escape
> the backslash or use the raw notation (according to the docs). Why do I need
> to both escape the backslash here and use the raw notation if I want to
> match a single backslash??
Backslash is special to both string literals and regular expressions. You must
escape them from both. Using 'r'aw strings means that the backslash is only
special to the regular expression.
More information about the Python-list