Andrew Wu wrote: > pattern3 = ''' > ^{ > ( > %s > | {%s} # Possible to have 1 level of nested lists > ,?)* # Items are comma-delimited, except for the last item > }$ > ''' % (pattern2, pattern2)
The above doesn't allow comma after the first instance of pattern2 and it doesn't allow space after either instance. Here is a version that passes your tests: pattern3 = ''' ^{ ( (%s | {%s}) # Possible to have 1 level of nested lists ,?\s*)* # Items are comma-delimited, except for the last item }$ ''' % (pattern2, pattern2) You might want to look at doing this with pyparsing, I think it will make it easier to get the data out vs just recognizing the correct pattern. Kent PS Please post in plain text, not HTML. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor