4

Possible Duplicate:
notepad++ Inverse Regex replace (all but string)

Let's say I have the following ...

http://whateverurl.com/is-not-wanted-but-it-is-here-anyway
http://icantbelieveibeenonthisallday.com/i-want-to-shoot-myself
http://hereiswhatireallywant.net/hey-there-sweet-thang
http://howsithangingloser.org/i-hope-someone-helps-you
http://heresanotherbeauty.net/that-i-want-to-be-all-up-in

I want to find only the lines that DON'T contain ".net/", so I can then replace it with nothing, hence delete.

I searched online and this site and found the (?!xxx) string, so I was trying to do the (?!.net/) but it seems that Notepad++ doesn't support that string or I may be using it wrong since I'm new to RegEx.

Can anyone tell me how to find a line that excludes a certain string of characters in Notepad++ ?

Community
  • 1
  • 1
Lost305
  • 175
  • 1
  • 3
  • 7

1 Answers1

8

As far as I can tell, Notepad++'s regex support doesn't let you actually capture the newline character. You are better off using this regex:

^.*\.net.*$

Replace it with nothing (now it is a blank line), then change the Search Mode to extended and replace \r\n\r\n with \r\n (or \n\n with \n if using Unix style line endings).

BoltClock pointed out that I am behind times, and that version 6 supports this. You can use this regex to find those lines and remove them:

^.*\.net.*(\r\n|$)

EDIT:

I appreciate your response, but you misunderstood what I said. I'm trying to find lines that DO NOT CONTAIN the .net/ to delete them. Can it be done?

Whoops. If you want to match lines that do not have .net in them, use this expression:

^(?!.*?\.net/).*\r\n

Works in Notepad++ 6.

vcsjones
  • 138,677
  • 31
  • 291
  • 286
  • 1
    It does starting from version 6.0 :) – BoltClock May 22 '12 at 22:38
  • I appreciate your response, but you misunderstood what I said. I'm trying to find lines that DO NOT CONTAIN the .net/ to delete them. Can it be done? Thanks again! – Lost305 May 22 '12 at 22:40
  • @BoltClock I failz. Thanks. Updated response, and maybe now I'll read release notes. – vcsjones May 22 '12 at 22:53
  • 1
    Wow dude, I been on this all day and all I had to do was upgrade my version of Notepad++. Thank you so much for your help. It worked! – Lost305 May 22 '12 at 23:59
  • @Lost305 you may accept **vcsjones**'s answer if it worked for you. This would also encourage you to participate in stackoverflow activities more. Thanks – Stat-R May 23 '12 at 13:14