Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Advanced find and replace in Notepad++

I’m trying to use Notepad++ for the first time and wanted to see if anyone here had some solutions for me.

I have a document that looks like this:

ex 1 
send power g1 g2 g3 g4 
ex 2 
send power g1 g2 
ex 3 
send power g1 f5 f3
ex 4 
send f5 f2 t5

… and so on, with various combinations of words after ‘send’. I just need to add a line (" this is number `#’") after each ‘send’ line, with the # matching the ‘ex #’ number…so it would increase by 1 each time. The result would be:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ex 1 
send power g1 g2 g3 g4
this is number `1' 
ex 2
send power g1 g2 
this is number `2'
ex 3 
send power g1 f5 f3
this is number `3'
ex 4 
send f5 f2 t5
this is number `4'

Any advice would be greatly appreciated!

>Solution :

find:

ex (\d+)\s+^.*$

replace:

$0\r\nthis is number `$1`

searches for ex followed by a number followed by 1 or more spaces and/or line breaks followed by the entire next line

replaces with: $0 the entire thing it found, a newline, this is number, and the number after "ex"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading