Hi,

I'm trying to delete contents of a .txt log file, matching on multiple
re.sub criteria but not sure how to achieve this.

Below is an illustration of what I am trying to achieve (of course in this
example I can combine the 3 re.sub into a single re expression but my
actual code will have a dozen plus expression I need to match on so easier
to keep them separate). Only the last re.sub will take effect in the
example below I need all 3 to take effect.


import re
o = open(r"c:\temp\outputfile.txt","w")
data = open(r"C:\Temp\infile.txt").read()
o.write( re.sub(".*<X>     ","",data) )
o.write( re.sub(".*<Y>     ","",data) )
o.write( re.sub(".*<Z>     ","",data) )
o.close()


Thanks in advance.
Jignesh
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to