Dreamweaver Tip: Search And Replace Tag Attributes

If you ever come across a situation where you want to replace tag attributes, this regular expression tip must prove extremely useful to you. Suppose you have a main table with lots of nested tables in it and you want to replace <table width = “400″> or <table width = “500px”> with <table width = “100%”> then you can put the regular expression at rescue instead of finding and replacing each attribute manually. I was working on a site developed by someone else but pages’ layout was not correct because of the fact that nested tables had been set to different pixel values rather than percentage values. What is more, some of the nested tables had longer width than that of main container table. So I had to replace width of those tables from pixels to percentage to correct the layout issue. You can use following regular expression at the dreamweaver Find dialog box to find all those tags having width set to pixels rather than percentage.


Oh, what if you wanted to search attributes having percentages rather than pixels, very simple regular expression:


Note that you can apply the similar regex for other attributes like height, etc. All you have to do is to change the word width to the desired attribute name.

When you start searching, make sure that “Use Regular Expression” checkbox is checked at the Find dialog.

Dreamweaver Tip: Search & Replace Code Snippets

dw_tip_tagWhile working on a project, I came across a need of deleting a piece of code from a number of pages as per the client’s requirements. Well if I would have done that manually then surely it would have taken a great deal of time, so I thought of creating some regular expression to do the trick and guess what it saved me a lot of time.

.Here is the regex:


What above means is that delete everything inside the <style></style> tags including the tags themselves. When you do the search-replace using dreamweaver, make sure that you check the Use Regular Expression check box at the Find and Replace dialog box. That’s it !! :)