import re
with open("in1.txt") as f:
lines = f.read()
m = re.sub(r'(?s)my _car_.*?(?=my|$)', '', lines)
m = re.sub(r'\n+', '\n', m)
print m,
2
solved Delete regex matching part of file
import re
with open("in1.txt") as f:
lines = f.read()
m = re.sub(r'(?s)my _car_.*?(?=my|$)', '', lines)
m = re.sub(r'\n+', '\n', m)
print m,
2
solved Delete regex matching part of file