How to replace multiple-line text

David Lees debl2nonospammyyy at bellatlantic.net
Thu Jul 11 00:19:58 EDT 2002


I would like to process a code file and substitute one multiline block
of code for another.  I know how to do this in Python by brute force
scanning through on a line by line basis until the first line of the
pattern is found then looping over the rest of the lines in the target
pattern for a match, then substituting in an output string multiline
substitution.  But I am sure there is a neater solution, perhaps using
regular expressions.  Could someone point me towards sample code or
something similar that I could modify.

Thanks in advance.

David Lees



More information about the Python-list mailing list