Kent Johnson wrote: > Do it all in one match / substitution using \1 to insert the value of > the paragraph group at the new location: > > In [19]: test = "self.source += '<p>' + paragraph + '</p>\n\n'" > > In [20]: re.sub(r"'<p>' \+ (.*?) \+ '</p>\n\n'", r"'<p>%s</p>\n\n' % > \1", test) > Out[20]: "self.source += '<p>%s</p>\n\n' % paragraph"
Interesting. Thanks! I was just doing some more reading of the re module, so now I understand sub() better. I'll give this a try too. Call me crazy, but I'm interested in regular expressions right now. :) -- http://mail.python.org/mailman/listinfo/python-list