Search for a text and copy the next lines of codes
-
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 -
You can (after locating them) select Line4, hold down Ctrl, and select Line8. Holding Ctrl, you can select many lines, with spaces between.

Hope I helped! -
The advice you offered is not good for what I suspect @Kev-Alejandrino wants.
-
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:

Here’s the text for the Find what box for convenient copy/paste use:
(?-s)SEARCHME(?:.*\R){3}\K.*After you press the
Mark Allbutton, 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.
-
@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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login