[issue35072] re.sub does not play nice with chr(92)

2019-02-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: chr(92) is a single backspace character ('\\'). Since backspace has special meaning in the replacement string, it should be escaped. re.sub(r'', r'\\', stringy_thingy) -- nosy: +serhiy.storchaka stage: test needed -> resolved status: open

[issue35072] re.sub does not play nice with chr(92)

2018-10-26 Thread Matthew Barnett
Matthew Barnett added the comment: @Ezio: the value of stringy_thingy is irrelevant because it never gets that far; it fails when it tries to parse the replacement, which occurs before attempting any matching. I can't reproduce the difference either. -- status: pending -> open

[issue35072] re.sub does not play nice with chr(92)

2018-10-25 Thread Ezio Melotti
Ezio Melotti added the comment: I'm assuming you want to replace double backslashes with single backslashes in stringy_thing, so I defined stringy_thingy and tried both your snippets but they are both failing: >>> stringy_thingy = r'foo\\bar\\baz' >>> print(stringy_thingy) # stringy_thingy

[issue35072] re.sub does not play nice with chr(92)

2018-10-25 Thread Samuel Warfield
New submission from Samuel Warfield : 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