deleting texts between patterns

micklee74 at hotmail.com micklee74 at hotmail.com
Fri May 12 03:51:19 EDT 2006


hi
say i have a text file

line1
line2
line3
line4
line5
line6
abc
line8 <---to be delete
line9  <---to be delete
line10  <---to be delete
line11  <---to be delete
line12  <---to be delete
line13 <---to be delete
xyz
line15
line16
line17
line18

I wish to delete lines that are in between 'abc' and 'xyz' and print
the rest of the lines. Which is the best way to do it? Should i get
everything into a list, get the index of abc and xyz, then pop the
elements out? or any other better methods? 
thanks




More information about the Python-list mailing list