I need help remembering what regex’s do what for me and instead of re-learning them over and over, I thought I would post the most useful ones. I do a lot of ‘Search and replace’ with config files so these are pretty specific.
Sometimes I need to just find the interfaces. (The can easily be filtered in IOS, but I tend to run multiple regex’s in my text editor)
\interface (.*) \switchport access vlan (.*)
Another common scenario is cleaning up access lists. For example in an ASA you get a bunch of stuff at the end. A little regex will take care of that.
( \(hitcnt\=0\)) 0x(.*)
When migrating from an old ASA to the new ASA-X, migrating the ACL’s can be a bear. One of the easiest ways to migrate is to grab the access lists that only have hit counts
show access-list | e hitcnt=0
Then take that list, use Find and enter the regex below and Replace with a blank.
\line [0-9]+ | (\(hitcnt\=.*\)) (.*) | \log (.*)
That will remove all the unnecessary areas and you will be left with just an ACL that you can copy-n-paste into the new ASA.