[Tutor] regular expression need help
kent37 at tds.net
Mon Nov 20 21:45:40 CET 2006
Hemantharaju Subbanna wrote:
> 'THIS \\ABC'
> I am looking for the expression that would tell me if
> the line has "\\"
First you should be aware that neither of these strings contains a
double slash. They contain a single slash which Python prints with an
extra slash as an escape. This is how Python prints and interprets
In : a='\\'
In : a
a only contains a single character, a single slash:
In : len(a)
If you explicitly print a, the escaping is not done and you see the
plain value of the string:
In : print a
If you want to know if a string contains a slash, just ask it using 'in'. :
In : '\\' in a
In : '\\' in 'THIS \\ABC'
> tried to escape, python complains of syntax
> Please help with the regular expression that would
> check for this double slash
> Thank you
> Sponsored Link
> Mortgage rates near 39yr lows.
> $310k for $999/mo. Calculate new payment!
> Tutor maillist - Tutor at python.org
More information about the Tutor