New submission from Patrick Foley:
The following code demonstrates:
import re
text = 'ab\\'
exp = re.compile('a')
print(re.sub(exp, text, ''))
If you remove the backslash(es), the code runs fine.
This appears to be specific to the re module and only to strings that end in
(even properly escaped) backslashes. You could easily receive raw data like
this from freehand input sources so it would be nice not to have to remove
trailing backslashes before running a regular expression.
----------
components: Regular Expressions
files: sample.py
messages: 292079
nosy: Patrick Foley, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Strings that end with properly escaped backslashes cause error to be
thrown in re.search/sub/etc. functions.
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file46822/sample.py
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue30133>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com