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.
or this would find one set of parentheses, simply loop to find more: