I'm a noob with RegEx patterns, so I'll apologize right away. :) I'm trying to take this string (note that there are some nested parentheses):
"(i) Test text (see § 123.1 of this Proper Name (PN) subparagraph) and additional test text (see § 123.2 of this subparagraph) along with more test text (including a parenthetical) to test the text. (See § 125.3 of this subparagraph for even more test text.) (Hello World!)"
And remove all the parenthetical statements which begin with "(See §" or "(see §" in order to get the following result:
"(i) Test text and additional test text along with more test text (including a parenthetical) to test the text. (Hello World!)"
I've tried using .split() and re.sub(), but can't seem to find a good solution. Here's the closest I've gotten:
import re
txt = '(i) Test text (see § 123.1 of this Proper Name (PN) subparagraph) and additional test text (see § 123.2 of this subparagraph) along with more test text (including a parenthetical) to test the text. (See § 125.3 of this subparagraph for even more test text.) (Hello World!)'
x = re.sub(r'\((s|S)ee §.*\)', r'', txt)
print(x)
It seems the that the '.*\)' is finding the last instance of ')' as opposed to the next instance. Is there a way to override this behavior, or rather, is there a better solution that I've missed entirely?
Thanks very much!