python regex help

Associate
Joined
23 Mar 2006
Posts
1,739
Evening all,

I'm after a bit of help with python regular expressions.

I want to search a file for an IP address, then put a # at the start of the next two lines. Being able to do the reverse would be good too (but I'm sure I could figure that out if I had the first bit).

Thanks
 
Thanks for the help, that seems like a reasonable way of doing it.

I am however having some problems with that, I get an invalid syntax error for the print line (in particular the = of end='' ). That the one line that I'm not sure what it's there for. If I don't have it then the file is empty after running the code.

If it makes any difference I am using python 2.7 not 3.
 
Back
Top Bottom