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
Yeah, it should be:
>>> import re >>> s = "AX(p>q)&E(qUr)" >>> p = re.compile("\(.*?\)", re.DOTALL) >>> new_string = p.sub("", s) >>> new_string 'AX&E'