'\\' in regex affects the following parenthesis?
voxiac at gmail.com
voxiac at gmail.com
Sat Apr 21 19:56:36 EDT 2007
Could someone tell me why:
>>> import re
>>> p = re.compile('\\.*\\(.*)')
Fails with message:
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
re.compile('\\dir\\(file)')
File "C:\Python25\lib\re.py", line 180, in compile
return _compile(pattern, flags)
File "C:\Python25\lib\re.py", line 233, in _compile
raise error, v # invalid expression
error: unbalanced parenthesis
I thought '\\' should just be interpreted as a single '\' and not
affect anything afterwards...
The script 'redemo.py' shipped with Python by default is just fine
about this regex however.
More information about the Python-list
mailing list