Python Splitting a string on multiple delimiters

When I was creating the page in my Scrapli and Flask Project for Multicast details. I had a requirement to split a string on multiple delimiters. As always Stack Overflow came to aid me.

The “show ip mroute” plain text output from the Nexus switch uses multiple delimiters for new lines, three specifically: “\n, \n\n, \n\n\n”.
I have an output of the dictionary I originally created that contained the output in a string format showing the new line characters.

This is how it should look. Very readable as is from the Cisco command line.

The Fix

For a quick fix, see the Stack Overflow. For my case I used the same, but adapted it when creating my dictionary. This worked perfectly, below is an excerpt. For the full script this can be seen in my Scrapli and Flask Project.

Leave a Comment

Your email address will not be published. Required fields are marked *