This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Сергей Снегирёв
Recipients ezio.melotti, mrabarnett, Сергей Снегирёв
Date 2016-12-19.15:38:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1482161936.1.0.52333974721.issue29015@psf.upfronthosting.co.za>
In-reply-to
Content
>>> path
'd:/\\temp\\\\'
>>> pat = '[{}]+'.format(re.escape('\\/'))
>>> re.sub(pat, '\\', path)
Traceback (most recent call last):
  File "<pyshell#78>", line 1, in <module>
    re.sub(pat, '\\', path)
  File "C:\Users\Сергей\AppData\Local\Programs\Python\Python35\lib\re.py", line 182, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "C:\Users\Сергей\AppData\Local\Programs\Python\Python35\lib\re.py", line 325, in _subx
    template = _compile_repl(template, pattern)
  File "C:\Users\Сергей\AppData\Local\Programs\Python\Python35\lib\re.py", line 312, in _compile_repl
    p = sre_parse.parse_template(repl, pattern)
  File "C:\Users\Сергей\AppData\Local\Programs\Python\Python35\lib\sre_parse.py", line 849, in parse_template
    s = Tokenizer(source)
  File "C:\Users\Сергей\AppData\Local\Programs\Python\Python35\lib\sre_parse.py", line 225, in __init__
    self.__next()
  File "C:\Users\Сергей\AppData\Local\Programs\Python\Python35\lib\sre_parse.py", line 239, in __next
    self.string, len(self.string) - 1) from None
sre_constants.error: bad escape (end of pattern) at position 0
>>> pat
'[\\\\\\/]+'
>>> 

In JS it works:

> 'd:/\\temp\\\\'.replace(new RegExp('[\\\\\\/]+', 'g'), '\\')
"d:\temp\"
History
Date User Action Args
2016-12-19 15:38:56Сергей Снегирёвsetrecipients: + Сергей Снегирёв, ezio.melotti, mrabarnett
2016-12-19 15:38:56Сергей Снегирёвsetmessageid: <1482161936.1.0.52333974721.issue29015@psf.upfronthosting.co.za>
2016-12-19 15:38:56Сергей Снегирёвlinkissue29015 messages
2016-12-19 15:38:55Сергей Снегирёвcreate