Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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

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. ;)

share|improve this answer
Do you mean he should do notepad++'s REPLACE ALL then. ok – barlop Feb 28 '14 at 12:10

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

share|improve this answer

Make sure that you are unchecking the option .matches newline.

enter image description here

share|improve this answer

So, I wanted to delete an entire line if it contained one of three words: LAB,RAD,TRAN. So what I did was a "find and replace" in Notepad++ where I match the whole line if it contains one of these words. Additionally though I have it match the new line (\n) and return carriage (\r) characters and replaced the whole thing blank (e.i. nothing). That way when it does the replace it remove all the text including the hidden characters that give you a new line. This made it so it didn't leave a blank line after replacement



share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .