Monday, March 11, 2013

Notepad++ RegEx Search & Replace

Often times we need to search and replace using more than just the default search words. If you are using Notepad++ for some basic code development, it has a nice feature of using regex - for both search & replace. Here is an example & I will probably add a few more as and when I use others.

Search for a hex color code (#000FF0) and remove the # sign or make it 000FF0.
Search: #(\w{6})
 - () : Marks the group. Here this will be the 1st so group 1.
- \w : Any character
- {6} : Limits the count to 6 characters
Replace: $1
 - The first matched group identified about.

Other serious choices would be sed on the unix shell.