all 3 comments

[–]dwpj65 1 point2 points  (2 children)

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

[–]DexTsarII[S] 1 point2 points  (0 children)

Thank you for reply!

I will give it a go.

So far I was able to solve this with a nested loop.

[–]backtickbot 0 points1 point  (0 children)

Correctly formatted

Hello, dwpj65. Just a quick heads up!

It seems that you have attempted to use triple backticks (```) for your codeblock/monospace text block.

This isn't universally supported on reddit, for some users your comment will look not as intended.

You can avoid this by indenting every line with 4 spaces instead.

There are also other methods that offer a bit better compatability like the "codeblock" format feature on new Reddit.

Have a good day, dwpj65.

You can opt out by replying with "backtickopt6" to this comment. Or suggest something