HOW TO : Advanced search and replace in Notepad++

Jhanvi asked me to help with editing a text file recently. She had a file in the format


'512'
'345'
'876'

and needed to convert it into the format below


INSERT INTO BLAH VALUE ('512');
INSERT INTO BLAH VALUE ('345');
INSERT INTO BLAH VALUE ('876');

There are multiple ways, one can do this. Here is how I did this using Notepad++, an open source text editor. I used the regular expression capability of Notepad++ it’s search and replace function.

  • Press “Ctrl + h” to bring up the search and replace window.
  • Replace the single quote at the beginning of the line by using ” ^’ “
  • Replace the single quote at the end of the line by using ” ‘$ “

Screenshots from the operation

The data in it’s original format

Replacing the first quote mark

Data after the first search and replace operation

Replacing the second quote mark

Data in the final format