I use Notepad++ and I need to delete all lines starting with, say "abc".
Attention, I don't need to replace the line starting with "abc" with a empty line, but I need to completely delete these lines.
How do I proceed (using regex, I suppose)?
I use Notepad++ and I need to delete all lines starting with, say "abc".
Attention, I don't need to replace the line starting with "abc" with a empty line, but I need to completely delete these lines.
How do I proceed (using regex, I suppose)?
Try replace
^abc.*(\r?\n)?
with
nothing
The ^
indicates the start of a line.
The .
means wild-card.
The .*
means zero or more wild-cards.
x?
means x
is optional.
The \r?\n
covers both \r\n
(generally Windows) and \n
(generally Unix), but must be optional to cover the last line.
Search for this regular expression
^abc.*\r\n
Replace with nothing.
Try the regex \nabc.*
in "Find and Replace" --> "Replace"
Leave "Replace With" field empty.
EDIT : This won't work with first like (because '\n' means "new line")
Searching a little bit more on regex in Notepad++ I discovered that the new line character is not \n
as I expected (Windows), but the \n\r
.
So, my regex replace expression should be:
Find: abc.*\r\n
Replace with: (nothing, empty field)
Press Ctrl+H to bring up the Replace
window. Put
^abc.*(\r?\n)?
in the Find what
and leave Replace with
empty. Select Reqular expression
and hit Replace All
.
This reqular expression handles all the edge cases:
abc
abc
and there is no new line at the end of the file.