Originally posted by ameat:
<STRONG>doing a site and just realized that none of the text i've placed in bold tags is showing up as bold in netscape 4.7...soo, in our sitewide style guide i realize that we've had this problem before and made a bold class. i'm using homesite and want to do an extended search and replace to replace everything within the bold tags into font tags specifying the class (i like to use spans but we standardized on the font tag...but that doesn't matter...)
can anyone help me write a regular expression for use in homesite (or bbedit) that will take <b>*</b> and place it into <font class="Boldtext1">*</font>?
trying to just find everything in the bold tags, i used this:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre>& amp;lt;font size=1 face=courier> /<b>[.]*<\/b>/ </font></pre><HR></blockquote>
but it wasn't finding anything...
any help is much appreciated because i really can't afford to sort through ~200 html files for anything in bold tags...
thanks</STRONG>
Your problem is that you placed the . in a character class [], so the regexp is looking for 0 or more
periods between bold tags. That's probably not what you meant.
However, this won't work either:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre>& amp;lt;font size=1 face=courier>
<b>.*<\/b>
</font></pre><HR></blockquote>
because regular expressions are greedy: They try to find the longest possible match. If, for example, you had the following line in your source:
I <b>hate</b> using the <FONT> tag, but they <b>make</b> me use it!
The above regexp would match this:
<b>hate</b> using the <FONT>tag, but they <b>make</b>
This is a difficult problem, in general, because you end up having to write an HTML parser. This might work:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre>& amp;lt;font size=1 face=courier><b>[^<]*</b></font></pre><HR></blockquote>
Read: Look for <b> followed by zero or more characters that are not <, followed by </b>.
This will fail when there is a tag within the <b> tag, e.g.:
<b>Click <a href="url">this link</a> now!</b>
Also, all regexps will fail to match tags that open on one line and close on another unless there's an option to allow them to match across lines (default behavior is that they don't).
If your editor supports Perl-style extended regular expressions, you can write a more general solution. I can post one once I'm back home with my Perl book.

But the above is about as close as vanilla regular expressions can get to solving your problem in one shot.
An alternative (which might be less of a head-ache) is a two-pass solution:
Search for <b> and replace with <font class="Boldstyle1">, then search for </b> and replace with </font>.
Hope this helps.
[ 04-05-2002: Message edited by: Amorph ]