I need to add specific keyword at the middle of each 3 lines
-
I need to add specific keyword at the middle of each 3 lines, I mean if i have
1111111111111111111
2222222222222222222
3333333333333333333
4444444444444444444
5555555555555555555
6666666666666666666
7777777777777777777
8888888888888888888
9999999999999999999and i want it to be
1111111111111111111
2222222222222222222
33333333 keyword 33333333333
4444444444444444444
5555555555555555555
66666666 keyword 6666666666
7777777777777777777
8888888888888888888
99999999 keyword 99999999999How could i do that using notebad++
-
Something like this seems like it would do it:
Find:
(?-s)(.+\R.+\R.{8})(.+\R)
Replace:${1} keyword ${2}
Search mode: Regular expression
Options: Wrap around
Action: Replace All -
@Alan-Kilborn thanks alot for help
Do you have idea if i wanted to add 2 or 3 keywords not just one, how to do that?
I mean1111111111111111111
2222222222222222222
33333333 keyword 33333333333
4444444444444444444
5555555555555555555
66666666 keyword2 6666666666
7777777777777777777
8888888888888888888
99999999 keyword3 99999999999 -
if i wanted to add 2 or 3 keywords not just one, how to do that?
Not with built-in Notepad++ regular expressions – at least, not alone.
Some users might tell you to put the list of replacements at the end of the file, with some sort of separator (like “=======”) before it, and then come up with some convoluted regular expression. That requires some manual setup to get it into the right format, and has some limitations depending on how big your file is (because it has to stuff things in memory to get it to work, and the memory has a limited size).
Others will suggest coding it in your favorite programming language, and leaving Notepad++ out of the equation. Or, as a compromise, to use one of the scripting plugins, like the PythonScript plugin – and, in fact, our “mathematical replacement” FAQ has a section on REPLACE FROM A SMALL LIST OF VALUES, which shows an implementation in PythonScript.
-
@faridalabib - to add to what @PeterJones just posted another thought is to replace with one keyword but then to do a second pass to “mailmerge” the list of desired keywords in place of the single keyword you had added. See this other post by @PeterJones and its follow-up posts on how to do the mailmerge.