At Friday 8/12/2006 02:53, Mike wrote:
I finally simplified my problem down to this simple case:
re.match(r'\\this', r'\\this')
Both the pattern and the string to match are identical raw strings, yet they
don't match. What does match is this:
re.match(r'\\\\this', r'\\this')
Perhaps you can understand better with a simpler example without backslashes:
>>> print re.match('(a)','(a)')
None
>>> print re.match(r'\(a\)', '(a)')
<_sre.SRE_Match object at 0x00C5CDB0>
You have to quote metacharacters if you want to match them. The
escape method is useful for this:
>>> re.escape('(a)')
'\\(a\\)'
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
--
http://mail.python.org/mailman/listinfo/python-list