I'm looking for a way to do this: I need to scan a text (paragraph or so) and look for occurrences of "<text-x> (<text-x>)". That is, if the text just before the open bracket is the same as the text in the brackets, then I have to delete the brackets, with the text in it.
How's this?
import re
bracket_re = re.compile(r'(.*?)\s*\(\1\)')
def remove_brackets(text): return bracket_re.sub('\\1', text) -- http://mail.python.org/mailman/listinfo/python-list