I am looking for a notepad++ regexp that contains a specific string. I then want to delete this whole line.

link|improve this question

67% accept rate
Make the regexp match the beginning of a line through the \n or \r\n at the ends of them (depending on the convention being used), and them make the replacement string nothing. – martineau Jan 25 '11 at 12:05
feedback

2 Answers

Well I don't think you can do it with one search-replace.

I'd do this.

Open up the search-replace, choose mode regex and search for:

^.*(string).*$ and let the replacement be \1 (this is the string marking the lines you don't want). This will leave lines with only the unwanted string and nothing else.

Then switch to the extended search and search for \r\nstring and leave the replacement blank. This will delete the lines with only the unwanted string in it.

There's probably a neater way to do it but this works.

Edit: and oh, check the first line of the document too for a line with only the unwanted string as this will miss those. As said, there's probably a better way. ;)

link|improve this answer
feedback

To find multiple strings on the same line you can use ^.\*(string).\*(string).*$

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.