I have some text in notepad++ like this. I would like to get copy the text in quotes in the line, whose next line have text as "No links found"

links in 'abc' as of time-spec 'now':
 No links found.

links in 'def' as of time-spec 'now':
 No links found.

links in 'xsdsw' as of time-spec 'now':
 No of links found: 3

Desired Output (Intermediate):

links in 'abc' as of time-spec 'now':
 No xlinks found.

links in 'def' as of time-spec 'now':
 No xlinks found.

Desired Output (final) :


This may not be a perfect solution, but could help if you have no other way.

With your file open, do a Find operation using the regular expression search mode. Use the following for your find criteria (adjust as needed):

links in '(.*)' as of time-spec 'now':\r\n No links found.

"Find" dialog

Click "Find All in Current Document" and you will get results that look similar to the following:

Results pane

In the results pane you should be able to Alt+click and highlight the text within the single-quotes. Then Ctrl+C to copy the values and then you can paste them into a new document or wherever you want them. Note: if the text within quotes is of varying length, you'll have to select more than you need in order to highlight each line as well as manually modify the pasted text to have a clean result.

Results pane with highlighted characters

| improve this answer | |

Another possibility is to use Replace with two sequential regular expressions. With your document open, press Ctrl+H to get the Replace dialog.

First, for "Find what" use:

links in '(.*)' as of time-spec 'now':\r\n.*\r\n No of links found: \d*\r\n

Leave "Replace with" as an empty text box. Click "Replace All" and this should effectively delete the lines you don't care to see.

Second, leave the Replace dialog open and now enter the following expression for "Find what"

links in '(.*)' as of time-spec 'now':\r\n No links found.\r\n

For "Replace with", put the following: \1

Click "Replace All" again and it should leave you with just the values you were looking to keep.

Animation of above steps

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.