[New-bugs-announce] [issue35072] re.sub does not play nice with chr(92)

Samuel Warfield report at bugs.python.org
Fri Oct 26 00:36:16 EDT 2018


New submission from Samuel Warfield <warfield at mymail.mines.edu>:

Bug with regex substitutions. When calling the re.sub() method directly
char(92), the double backslash charecter as the replacement, throws an
exception. Whereas compiling a regex object then calling its own .sub()
method works completely fine. I did a quick look through the bug tracker 
search for similar issues and none were reported.

# Breaks
re.sub(r'\\\\', chr(92), stringy_thingy)

vs 

# Works
parser = re.compile(r'\\\\')
parser.sub(chr(92), stringy_thingy)

# Where stringy_thingy is a string that is being substituted

----------
components: Regular Expressions
messages: 328509
nosy: Samuel Warfield, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.sub does not play nice with chr(92)
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35072>
_______________________________________


More information about the New-bugs-announce mailing list