D3841: stringutil: add a new function to do minimal regex escaping

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Wed Jun 27 09:47:19 EDT 2018


yuja added a comment.


  > +# regex special chars pulled from https://bugs.python.org/issue29995
  >  +# which was part of Python 3.7.
  >  +_respecial = pycompat.bytestr(b'()[]{}?*+-|^$\\.# \t\n\r\v\f')
  >  +_regexescapemap = {ord(i): (b'\\' + i).decode('latin1') for i in _respecial}
  
  The Py3.7 version also includes '&' and '~'.
  
  https://github.com/python/cpython/blob/v3.7.0rc1/Lib/re.py#L248

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3841

To: durin42, #hg-reviewers, pulkit
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list