HTML and CSS Reference
signs, as shown here, throughout one of my sites:
<a href=="../../index.html">Cafe au Lait</a>
Consequently, links were breaking all over the place. The first step was to find out how broad the problem was.
In this case, the mistaken string was constant and was unlikely to appear in correct text, so it was easy to
search for. This problem turned up 4,475 times in 476 files, as shown in the HyperSearch results in Figure 2.7 .
Figure 2.7. jEdit search results
[View full size image]
When there aren't a lot of mistakes, you can click on each one to open the document and fix it manually.
Sometimes this is needed. Sometimes this is even the easiest solution. However, when there are thousands of
mistakes, you have to fix them with a tool. In this case, the solution is straightforward. Put href= in the
"Replace with" field, and then click the "Replace all" button.
Do be careful when performing this sort of operation, though. A small mistake can cause bigger problems. A bad
search and replace likely caused this problem in the first place. You should test your regular expression search
and replace on a few files first before trying it on an entire site.
Most important, always work on a backup copy of the site, always run your test suite after each change, and
always spot-check at least some of the files that have been changed to make sure nothing went wrong. If
something does go wrong, an editor with undo capability can be very useful. Not all editors support multifile
undo with a buffer that's large enough to handle thousands of changes. If yours doesn't, be ready to delete your
working copy and replace it with the original in case the search goes wrong. Like any other complex bit of code,
sometimes you have to try several times to fully debug a regular expression.
Often, you don't know exactly what you're searching for, but you do know its general pattern. For example, if