Due to regex engine in Python 3.7+ (contain 3.7) is different form Python 3.6 and below, Python should be divided into two parts. Regex101 only supports the eariler versions.
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:02:33) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.sub(r'\d*?|x', '-', 'x1')
'-x-1-'
run in Python 3.7:
Python 3.7.3 (default, Apr 24 2019, 13:20:13) [MSC v.1915 32 bit (Intel)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.sub(r'\d*?|x', '-', 'x1')
'-----'
Feature
Due to regex engine in Python 3.7+ (contain 3.7) is different form Python 3.6 and below, Python should be divided into two parts. Regex101 only supports the eariler versions.
Take '\d*?|x' for example:
run in regex101:
run in Python 3.6:
run in Python 3.7: