I am trying to remove a block of text in the apache configuration file, specifically virtualhosts. I need to remove the virtualhost containers including the < VirtualHost> markers.
Stuff
<VirtualHost asdfalsdkf:*>
asldkfjasl;dkfjasldkfj
asdfljasldjf;laksdfj
a;lsdkfj;laksjdfas
asldkfjasldfkj
3495034ijfgdl9)_*)(%$
more stuff
</VirtualHost>
stuff
So far I have tried to regex it out. but it is not changing the file. I am actually trying to update the file and remove the code.
This is what I have so far that is not working.
for line in fileinput.input('/etc/apache2/apache2.conf.replace',inplace=True):
sys.stdout.write(re.sub(r'<VirtualHost.*?>.*?</VirtualHost>','',line))
<VirtualHost ...and would thus be invalid.