I wanted to understand this regular expression in Python: \([^\(\)]*\
The full code is below. It reverses text inside of parentheses.
import re
def reverseParentheses(s):
s_new = s
count = 0
while True:
mat = re.findall(r'\([^\(\)]*\)',s_new)
if not mat:
break
for i in mat:
temp = re.sub(r'\(|\)', '', i)
s_new = re.sub(re.escape(i), temp[::-1], s_new)
return(s_new)