["python","python-2.7"]
Remove text between () and []

I have a very long string of text with () and [] in it. I'm trying to remove the characters between the parentheses and brackets but I cannot figure out how. The list is similar to this: x = "This is a sentence. (once a day) [twice a day]" This list isn't what I'm working with but is very similar and a lot shorter.
This should work for parentheses. Regular expressions will "consume" the text it has matched so it won't work for nested parentheses. import re regex = re.compile(".*?\((.*?)\)") result = re.findall(regex, mystring) or this would find one set of parentheses, simply loop to find more: start = mystring.find("(") end = mystring.find(")") if start != -1 and end != -1: result = mystring[start+1:end]