I have a string s with nested brackets: s = \"AX(p>q)&E((-p)Ur)\"
s
s = \"AX(p>q)&E((-p)Ur)\"
I want to remove all characters between all pairs of brackets and
>>> import re >>> s = "AX(p>q)&E(qUr)" >>> re.compile("""\([^\)]*\)""").sub('', s) 'AX&E'