Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegEx to Exclude line using Notepad++ [duplicate]

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

like image 307
Lost305 Avatar asked Feb 20 '23 09:02

Lost305


1 Answers

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.

like image 84
vcsjones Avatar answered Feb 28 '23 12:02

vcsjones