sujin
sujin

Reputation: 2853

delete N lines before if find matches in Notepad++

I want to delete 3 lines upwards if find matches in notepad++ using regular expression

Example

LINE 1
LINE 2

LINE 3
LINE 4
LINE 5

LINE 6
LINE 7

If regular expression match LINE 5 then output has to be like be

LINE 1
LINE 2



LINE 6
LINE 7

I have tried with many replace pattern but no success. Kindly help me on this.

Upvotes: 0

Views: 2074

Answers (1)

abc123
abc123

Reputation: 18763

Regex 101

.*\n.*\nLINE 5

Description

.* matches any character (except for line terminators)
  * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
.* matches any character (except for line terminators)
  * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
LINE 5 matches the characters LINE 5 literally (case sensitive)

Upvotes: 1

Related Questions