Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

[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=

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.

share|improve this question

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


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:


and replace with:


share|improve this answer
for some reason, notepad++ uses the SciTE implementation of regular expression which is a line by line search pattern. That's why this is a two step process, you can't use regular expression in Notepad++ to find line breaks. You might want to check out Textpad if you are going to be doing this kind of work all of the time. – Doltknuckle Nov 17 '09 at 17:07
Sure, but as I detailed in my answer you CAN find line breaks using Extended search mode. Is it a problem to run two steps? And while I did use and promote Textpad for years, I switched, and the asker asked specifically about Notepad++. – JMD Nov 17 '09 at 17:18

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="">

share|improve this answer

I went kind of mad today, cause I spent so much time trying to find the Regex replace option. For some reason, It's no longer int the regular find / replace dialog you getwhen you press Ctrl+F or Ctrl+H. There is a new dialog for it using Ctrl+R. Wish it were in the same place as the regular find/replace as it would be simpler to find...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.