Notepad++ regex -> newLine

13,600

Solution 1

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.

Solution 2

Search for this regular expression

^abc.*\r\n

Replace with nothing.

Share:
13,600
serhio
Author by

serhio

I like .NET and started learning PHP. email: gserhio[at]gmail[.]com

Updated on June 11, 2022

Comments

  • serhio
    serhio almost 2 years

    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)?

  • Neozaru
    Neozaru about 11 years
    Yes. And << (^|\r?\n)abc.*\r?\n >> for "abc...<something else>"
  • ellak
    ellak about 11 years
    This would match lines with abc in the middle also.
  • Mohammad Dehghan
    Mohammad Dehghan about 11 years
    Does not work for last line of the file, when the file has no new line at the end.
  • Mohammad Dehghan
    Mohammad Dehghan about 11 years
    Does not work for last line of the file, when the file has no new line at the end.