I have this regular expression that finds a line with the world "Title Sequence" matches the 2 previous lines above it, the next 1 to 5 lines below it and finally a line with a year in it (four digits).

((^.*$)\r\n){2}(^.*Title Sequence.*$\r\n)((.*\r\n){1,5}^.*, \d{4}.*$)

This works fine but when I try to bookmark all these lines int notepad++ it bookmarks only the first line of every block. How do I make it bookmark every line in the block so I can then delete everything but the bookmarked lines?


I don't think there is a way to do it in one go, but since it's only 8 lines you are interested in, there is a solution that would take 8 iterations.

You can use the \K operator "Keep The Text Matched So Far out of The Overall Regex Match".

So in the example


You would fist bookmark this, for the first line


Then this, for the second


And this for the third

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