Community
    • Login

    Search for a text and copy the next lines of codes

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 363 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.
    • Kev AlejandrinoK
      Kev Alejandrino
      last edited by

      Hi all,

      Is there any way where I search for a text and copy the next lines of codes?

      Sample text:
      Line1Texttosearch SEARCHME
      Line2someTextHere
      Line3someTextHere
      Line4copyThisLine IWANTTOCOPYTHISLINE0001
      Line5Texttosearch SEARCHME
      Line6someTextHere
      Line7someTextHere
      Line8copyThisLine IWANTTOCOPYTHISLINE0002
      …

      In here I have to find the keyword “SEARCHME”, it will give multiple results which is the Line1 and Line5. What I want to copy is the contents of the next two lines for each keyword which Line4 and Line8. The result of what I copy to clipboard would be the Line4 and Line8 only.

      Result:
      Line4copyThisLine IWANTTOCOPYTHISLINE0001
      Line8copyThisLine IWANTTOCOPYTHISLINE0002
      …

      I don’t mind copying the Line3, Line4, Line6 and Line7 if it makes it easier.

      Kind Regards,
      Kev

      Alan KilbornA 1 Reply Last reply Reply Quote 2
      • Lucca PelucaL
        Lucca Peluca
        last edited by Lucca Peluca

        You can (after locating them) select Line4, hold down Ctrl, and select Line8. Holding Ctrl, you can select many lines, with spaces between.
        Capture.PNG
        Hope I helped!

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Lucca Peluca
          last edited by

          @Lucca-Peluca

          The advice you offered is not good for what I suspect @Kev-Alejandrino wants.

          1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @Kev Alejandrino
            last edited by

            @Kev-Alejandrino

            Thanks for the fairly decent problem description!

            For a possible solution:

            Try a “marking” operation; start by pressing Ctrl+m and then filling out the Mark tab this way:

            79e37664-511b-4654-889f-255ad96b64b9-image.png

            Here’s the text for the Find what box for convenient copy/paste use: (?-s)SEARCHME(?:.*\R){3}\K.*

            After you press the Mark All button, you should see the text you want highlighted in red like I show.

            At that point it is a simple matter of pressing the Copy Marked Text button.

            1 Reply Last reply Reply Quote 3
            • Kev AlejandrinoK
              Kev Alejandrino
              last edited by

              @Alan-Kilborn said in Search for a text and copy the next lines of codes:

              (?-s)SEARCHME(?:.\R){3}\K.

              Thank you! It works just what I wanted.

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