Perhaps it’s just the influence of Inkle’s new Heaven’s Vault game, with the epigraphy of its mysterious alien inscriptions, but I’ve taken a bit of a shine to regex. My first failed tests with the Notepad++ regex were obviously with the ‘wrong type’ of regex, as I now know there are slightly different versions for Windows, Linux etc. But I’ve now found commands that do work for me.
The following were found by scouring forums and were then tested while learning more about Notepad++ and how it works (it’s a lot deeper than it looks). They’re actual working practical examples, tested and working with the latest Notepad++ on Windows 64-bit. My testing suggests that exactly the same macros run differently in the old 32-bit vs. new 64-bit Notepad++. Since (so far as I can tell) plugin activity cannot be recorded in macros, I assume the difference is due to regex support.
Please note that I am clueless about writing these things, only knowing how to search for, find and test them. So don’t ask me to advise you on their devising or tweaking. My many thanks especially to guy038 at the Notepad++ forum, and many and various others, for writing these and helping others find solutions. I found that the search-engine Yippy, based on Bing, is especially good at finding these things, and will almost inevitably lead you to guy038. But, so far as I know, he has not made a regex ‘keyring’ or a ‘cookbook’ or suchlike. Hence my need to collect some working examples here under practical headings.
All but one of these regexes (regexii?) run in the ‘Find’ or ‘Replace’ box in Notepad++. One needs to run in the ‘Mark’ tab in the same box…
On your keyboard, it’s useful to know that Ctrl + Home will take your text cursor (‘caret’) back to the top of the Notepad++ page, which may be useful if you are building these commands into a recorded macro.
Lastly, using regex to fiddle with public HTML seems to be frowned on, so I suggest the following are useful for certain offline text cleaning and data-swivelling operations, not for mission-critical coding or live pages.
The list has to be posted here in plain text as a .PDF. I had a blog post all done and polished, but then found that WordPress.com blogs make an utter mess of posted regex code, even when wrapping it with the code tags which are supposed to protect snippets of code! So here are the working regexes in a handy four-page .PDF file…