input of my file is:

< Hi James
> Hi Jamy
< What about weekend?
> What about sat/sun?

and output should come :

< Hi James
> Hi Jamy
< What about weekend?
> What about sat/sun?

Means deleting the contents of the line before '>' and '<'.

Can anyone help. Thanks in advance.

1 Answer 1


In Notepad++ 6.9.1 I was able to do this by selecting Search->Replace... and putting the following regular expression in the "Find what:" field:


Then leaving the "Replace with:" field empty and setting a Search Mode of "Regular Expression", leaving ". matches newline" unchecked, and pressing "Replace All".

How It Works

(^[^<>\n]+)\n|\n[^<>\n]+ is a Notepad++ Regular Expression.

(^[^<>\n]+)\n Is a sub-expression that matches lines that don't start with < or >. This matches the first line of text in your example input "bsg23".

| Indicates alternation between two sub-expressions

\n[^<>\n]+ Matches a newline followed by characters that are not <, >, or a newline. This matches the newlines at the end of lines that start with < or > and the following text on the next line.

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.