Q:

Python Regex - How to remove text between 2 characters

How can I remove anything between ")" and "|"
For example,
str = "left)garbage|right"

I need the output to be "left)|right"

A:

>>> import re
>>> s = "left)garbage|right"
>>> re.sub(r'(?<=\)).*?(?=\|)', '', s)
'left)|right'

>>> re.sub(r'\).*?\|', r')|', s)
'left)|right'

