Fixing Other SEO Firms' Mistakes Using Dreamweaver Wildcard Search and Replace
All too often we take over search engine optimization efforts for a new client, only to find that the last SEO firm or SEO professional they were using did so many things wrong it's going to be a major effort just to clean up their mess, let alone start making progress (although I suppose cleaning up is a form of progress, but you know what I mean).
Case in point, we just took over doing SEO for a billion-dollar enterprise with a substantial website, and what do you know, the last SEO people working on it stuffed the site full of stuffed image alt tags, stuffed keyword meta tags, stuffed url title tags, etc. And they were very thorough with their work in that they didn't repeat the content of the various tags, they mixed it up in every case so they aren't the same and therefore you can't do a simple search and replace to find them all. The slow way to get things done would be to edit every page by hand, deleting the offending code, but thankfully Dreamweaver lets you do a wildcard search and replace that is a lifesaver.
Here's how it works:
First, - [^"]* - Remember that code. You'll learn to love it. Once again, that code is [^"]*.
Now let's say you've got a stuffed image tag like this:
<img src="whatever.gif" alt="keyword 01, keyword 02, keyword 03, keyword 04, keyword 05, keyword 06">
and then you have another one in a separate file that looks like this (notice the numbers on the keywords change):
<img src="whatever.gif" alt="keyword 01, keyword 03, keyword 06, keyword 08, keyword 05, keyword 06">
and you want to replace both of them with this:
<img src="whatever.gif" alt="keyword 01">
And let's say it's not just two tags, but two hundred, and they're all mixed up, except that they all have the common attribute that keyword01 comes first in all cases. Do a search and replace, and search for this:
<img src="whatever.gif" alt="keyword 01[^"]*">
and then replace it with:
<img src="whatever.gif" alt="keyword 01">
IMPORTANT: Check the box that says "use regular expression"
In my case, I'm able to change anywhere from 10-200 alt tags at once, which is dramatically speeding up the process. However, I'm lucky in that when I do a search, there is more than one alt tag that contains the first keyword at the beginning, otherwise when I did the wildcard search it would still only hit one match. If that were the case, I would do a search and replace like this:
<img src="whatever.gif" alt="[^"]*">
to:
<img src="whatever.gif" alt="">
This will empty out all the alt tags on the entire website. Granted, then I have to worry about filling them in again, but I was going to have to do that anyway, so I might as well speed up the process of deleting the junk that's in them.
You could do the same thing to delete all the meta keyword tags on a site at once, even if the keywords in each tag on each page are different.
Now I agree there should be a better way to do this using some specialize SEO tool, but if it's out there I don't know about it. If you do, let me in on the secret.
Comments
You could also do this using shell/terminal and a perl regular expression like this:
perl -pi -e 's/find/replace/g' *.txt
where FIND is the text you want to find and REPLACE is the text you want to replace with. this will fidn and replace in all files that end in txt, so you could change this to do html or whatever. you can use perl's regular expressions much in teh same way ouy use dreamweaver
Posted by: web design blog at April 7, 2008 12:38 AM
A beautiful method I must say! The most beautiful part about this little code snippet is that you can use it to replace just about anything - including those most irritable snippets of code placed in invisible layers and the margins of a page that some unnamed SEO 'professionals' are still using to boost their clients rankings. Obviously it's not exactly a catch-all, but definitely a keeper for those of us thoroughly entrenched in th Macromedia Dreamweaver way of instituting clean html. Thanks a bunch!
Posted by: Jon Suarez at May 5, 2008 08:37 PM

