Ah - thanks for the correction! I missed the extra grouping and the extra spacing ... doh! Sorry about the HTML-formatted e-mail ...
Thanks also for the pyparsing variant as well - I didn't know the module existed before! Andrew On 11/1/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > 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