Previously, we’ve blogged about customizing the Toolbar within Notepad++ and, in my case, the benefit in doing so was to add some key functions to the Toolbar from the “XML Tools” plug-in I often use. In working with a lot of XML, XSLT and even HTML within Notepad++, I often have a need to find, or even find/replace, specific tags or script blocks. Notepad++ makes this easy with support for RegEx via the “regular expression” Search Mode.
Given the following XML snippet, let’s look at some use cases for RegEx finds:
In Notepad++, we could easily find our <SetList> element using this RegEx:
Then if we wanted all the <SetVar> elements, regardless of their Name attribute or value, we could use this RegEx:
If we wanted to be more explicit and say only find the <SetVar> element whose Name attribute began with an “E”, we could use:
Or perhaps we want to find all the <SetVar> elements where the text value is “TRUE”:
As you can see, these simple tricks could save you time & effort if wanting to find specific tags – or clean up using Find/Replace with a blank replace – using the regular expression Search Mode in Notepad++.