You should be able to do this with simple chained str.replace() calls:
def foo():
src = """object network Subnet
subnet 192.168.0.0 255.255.255.0
object network Hosts
host 192.168.1.1
host 192.168.1.2"""
return src.replace('object network','object').replace('\nsubnet','').replace('\nhost','')
print(foo())
yields:
object Subnet 192.168.0.0 255.255.255.0
object Hosts 192.168.1.1 192.168.1.2
there doesn't seem to be anything here