Home > Tutorials, the webmaster series > Multiple File Search & Replace using Dreamweaver MX and regular expressions

Multiple File Search & Replace using Dreamweaver MX and regular expressions

About a month ago I needed to do some work on a site where I needed to change a lot of code on every page. I set up IIS on my machine and copied the site to it. I then set up Dreamweaver so that I would work on the site locally. When I opened Dreamweaver I had all the files for my site listed on the left side. I found that when I did a search and replace in Dreamweaver I had the option to do it to the entire current site. That was real cool and I was using for some simple things. I got to a point where I needed to switch out some tags with tags. I like to use normal HTML whenever I can especially header elements.

The problem was that I need to find a string but leave the stuff inside the tags alone. Dreamweaver allows the use of regular expressions. I know very little about regular expressions so I was looking everywhere on how to do this. I finally found one document online that told me how. I can’t remember what that was but here is what I learned. I use (.+) in the search and $1 in the replace. If I want to find <span class=”HeaderL1″>My Heading</span> with <h1>My Header</h1> I search for <span class=”HeaderL1″>(.+)</span> and put <h1>$1</h1> in the replace field. I then tell it to search and replace the entire site. Make sure to have “use regular expressions” checked.

Categories: Tutorials, the webmaster series Tags:
  1. November 6th, 2007 at 23:29 | #1

    Great article, i like Dreamweaver very much, because we can create our web page easily than any other html editor, ya i agree its tough to remember regular expression, but being a computer student i can, Nice idea you followed, but you should careful about this, sometimes, it make us change original expression, so be careful while doing search and replacement .

  1. No trackbacks yet.