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

Yuya Nishihara yuya at tcha.org
Wed Jun 27 09:47:07 EDT 2018


> +# 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


More information about the Mercurial-devel mailing list