Re: escapes in regular expressions

2006-05-21 Thread Heiko Wundram
Am Sonntag 21 Mai 2006 19:49 schrieb James Thiele: > >>> re.match('\d', '7').group() >>> print '\d' \d > >>> re.match('\\d', '7').group() >>> print '\\d' \d '\d' evaluates to \d, because d is not a valid escape sequence. '\n' evaluates to newline, because n is a valid escape sequence. '\\' eva

Re: escapes in regular expressions

2006-05-21 Thread Paul McGuire
"James Thiele" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I was helping a guy at work with regular expressions and found > something I didn't expect: > > >>> re.match('\d', '7').group() > '7' > >>> re.match('\\d', '7').group() > '7' > >>> > > It's not clear to me why these are th

Re: escapes in regular expressions

2006-05-21 Thread Dennis Benzinger
James Thiele schrieb: > I was helping a guy at work with regular expressions and found > something I didn't expect: > > re.match('\d', '7').group() > > '7' '\d' is not recognized as a escape sequence by Python and therefore it is left unchanged in t

escapes in regular expressions

2006-05-21 Thread James Thiele
I was helping a guy at work with regular expressions and found something I didn't expect: >>> re.match('\d', '7').group() '7' >>> re.match('\\d', '7').group() '7' >>> It's not clear to me why these are the same. Could someone please explain? -- http://mail.python.org/mailman/listinfo/python-lis