Dreamweaver – Find and Replace

I’m working on converting a web site from tables and old fashioned tags to CSS and semantic page structure. And I thought to myself, wouldn’t it be nice if I could easily do a ‘Find and Replace’ in Dreamweaver or Homesite, where I can determine the starting tag and ending tag, with the text in the middle acting like a variable.

So I asked my friend if he knew of a way to do that, and with his help we figured it out using regular expressions. Here’s the breakdown…

In the dialog box, this text goes in the ‘Find’ field:
<span class=subtitle>([^<]*)</span>

And this in the ‘Replace’ field:
<h4>1</h4>

You need to make sure that the ‘Regular Expressions’ checkbox is CHECKED. The text between the tags in the examples above are the regular expressions.

If you want to have more than one “variable”, then you’ll need to add on numbers in the replace field, like this…

Find field:
<div style="padding-bottom: 5px; margin-top: 30px;" class=subtitle><a
href="([^<]*)">([^<]*)</a></div>

Replace field (number each variable):
<h2><a href="1">2</a></h2>

2 Comments

  1. FoundByGoogle on May 7, 2009 at 6:36 pm

    AWESOME! What an incredible time-saver… Thanks very much for posting this info!

  2. Nicole on May 7, 2009 at 9:36 pm

    I’m so glad it was helpful!

Leave a Comment