mathieu, stop writing complex REs like obfuscated toys, use the re.VERBOSE flag and split that RE into several commented and *indented* lines (indented just like Python code), the indentation level has to be used to denote nesting. With that you may be able to solve the problem by yourself. If not, you can offer us a much more readable thing to fix.
Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list