
Now just do a replace in Notepad++ (make sure to choose the regular expression radio box) and replace that text with nothing so that the matching ports are removed from the text configuration. Interface GigabitEthernet\d*\/\d*\/\d*\r\n switchport access vlan 232\r\n spanning-tree portfast\r\n So the full search string we are looking for is now: These can be found using \r for carriage return and \n for new line. The only remaining issue now is the carriage returns in the file. \/ = This is the escape character “\” followed by the forward slash character “/” which searches for a forward slash “/”īy combining those together we have a string that will search for all the ports in the configuration. * = repeat the previous token (the \d in this case from 0 to infinite times).

Where the search terms are the following: To do this we need to search for the following: Our main problem is that we need to search through all the ports and ignore the port numbers in the example above, so that we can find all the ports regardless of number: “interface GigabitEthernet2/0/27”. There’s a great regex testing tool here: so you can experiment with building your own regex expressions. Regex is a very powerful method for handling text files but can be very confusing. That’s where the regular expression (regex) feature of Notepad++ can help. While a regular Find/Replace operation would find the particular lines to be deleted, it wouldn’t be able to handle the changes in the port numbers. Ideally, we’d just flag port 2/0/28 as different in the example above, since it doesn’t match the other two ports.

The example text would look something like the following: Yesterday I was asked by a colleague to parse a Cisco switch configuration to find ports that are configured differently from an example port on a switch with several hundred ports on it. Same thing with other formats like XML, PowerShell, VBScript, etc. Open up an HTML file in Notepad++ and it knows about HTML formatting and changes the text color appropriately. You can open up multiple text files in tabs in Notepad++ and search across all the documents at the same time.Ĥ. I use this all the time when comparing firewall or switch configurations to see what has changed(or what needs to change when doing firewall migrations to new hardware.ģ. There is a great Compare plugin in the Plugin Manager that lets you easily compare two text files.

Can handle the large text files (think 100MB log files) with ease.Ģ. Notepad++ is one of my favorite text editors and I tend to install it on any computer I’m working with. While the built-in Windows Notepad only gets you so far, the free GPL Licensed Notepad++ has some big advantages:ġ.
