Monday, January 24, 2011

Notepad++ : Regular Expressions

Using regular expressions with Notepad++ can be quite rewarding apart from saving time.

For e.g. if you want to copy a set of 100 files for which you have a list. For one file for e.g. you want to convert

C:\MyDocs\Temp\Files\delme\sets\ABC\view\fSet\applicantGridAllApplicants.jsp

with

xcopy C:\MyDocs\Temp\Files\delme\sets\ABC\view\fSet\applicantGridAllApplicants.jsp D:\temp\upgrade\hover\Jan25\sets\ABC\views\fSet\



Use Notepad++, in replace dialog, use the following in "Find What" and "Replace What" respectively.

(.*)(sets\\)(.*)(fSet\\)(.*)(jsp)

xcopy \1\2\3\4\5\6 D:\\temp\\upgrade\\hover\\Jan25\\\2\3\4


Remember to "Regular Expression" as Search Mode.