Notepad++ find string with a new-line and replace

[Notepad++ Question]

How do I use find-and-replace to replace the attribute of a series of tags using expression?

Case scenario:

Let's say I have a couple of lines of something like this:

<li><a title="Bla bla" href=
    "http://www.url.com/etc">Text</a></li>

And I want to replace them with this:

<li><a title="Bla bla" href="">Text</a></li>

Note the new line and double tabs on the original.


Speaking specifically about the newline and double-tabs, using the Extended Searched Mode find:

\r\n\t\t

and replace with:

(blank, nothing, empty string)

And assuming you are wanting to remove the URL from the href, leaving a blank reference, you'll want to use the Regular expression Search Mode to find:

href=\"(insert-http-url-regex-here)\"

and replace with:

href=\"\"


AFAIK you can't use regular expression-replace over multiple lines (in Notepad++) so you have to make them one-liners first. Here is how to do that using a macro:

  1. Hit CTRL+F and enter href= then hit Enter and Escape
  2. Start recording a macro (CTRL+SHIFT+R)
  3. Press Delete 3 times (once for linebreak, twice for tabs)
  4. Finish recording the macro (CTRL+SHIFT+R again)
  5. Hit F3 to search the next href= occurence.
  6. Execute macro (CTRL+SHIFT+P)
  7. Continue with Step 5 until all occurences are replaced.

Note: If all your href= appearences are the same, you can also put the search into the macro (i.e. switch steps 1 and 2) and execute the macro until everything is on one line.

Now you can do a search & replace with regular expressions (CTRL+H):
Search for: href=".*">
Replace with: href="">