Showing posts with label Regular Expressions. Show all posts
Showing posts with label Regular Expressions. Show all posts

Friday, 2 January 2015

Regular Expression Find and Replace in Notepad++

So today I found myself editing a page from our internal Wiki and the formatting was completely and utterly up: Headings were all wrong, some at level 2, others at level 3 and quite a few other things were wrong as well.

I copied and pasted the page to Notepad++ and decided to use Find and Replace, but how could I use Regular Expressions to find and replace.

Simple, it turns out that all that's needed is to use capturing groups.

Input Text:
1. == Section 1 ==
....
2. == Section 2 ==
....
3. === Section 3 ===
....
4. == Section 4 ==
Desired Output Text:
1. === Section 1 ===
....
2. === Section 2 ===
....
3. === Section 3 ===
....
4. === Section 4 ===
So this is the regular expression I used:
Find Regular Expression Explanation:
Replace Regular Expression Explanation:

Add = to the end of each capturing group

Hope this helps