• Login
Community
  • Login

I need to add specific keyword at the middle of each 3 lines

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 4 Posters 478 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F
    faridalabib
    last edited by Jan 16, 2024, 1:19 PM

    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
    9999999999999999999

    and i want it to be

    1111111111111111111
    2222222222222222222
    33333333 keyword 33333333333
    4444444444444444444
    5555555555555555555
    66666666 keyword 6666666666
    7777777777777777777
    8888888888888888888
    99999999 keyword 99999999999

    How could i do that using notebad++

    A 1 Reply Last reply Jan 16, 2024, 1:48 PM Reply Quote 0
    • A
      Alan Kilborn @faridalabib
      last edited by Jan 16, 2024, 1:48 PM

      @faridalabib

      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

      F 1 Reply Last reply Jan 16, 2024, 9:15 PM Reply Quote 5
      • F
        faridalabib @Alan Kilborn
        last edited by Jan 16, 2024, 9:15 PM

        @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 mean

        1111111111111111111
        2222222222222222222
        33333333 keyword 33333333333
        4444444444444444444
        5555555555555555555
        66666666 keyword2 6666666666
        7777777777777777777
        8888888888888888888
        99999999 keyword3 99999999999

        P 1 Reply Last reply Jan 17, 2024, 5:00 PM Reply Quote 0
        • P
          PeterJones @faridalabib
          last edited by PeterJones Jan 17, 2024, 5:01 PM Jan 17, 2024, 5:00 PM

          @faridalabib ,

          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.

          M 1 Reply Last reply Jan 17, 2024, 8:39 PM Reply Quote 2
          • M
            mkupper @PeterJones
            last edited by Jan 17, 2024, 8:39 PM

            @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.

            1 Reply Last reply Reply Quote 1
            1 out of 5
            • First post
              1/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors