
Need help substituting text except when in an HTML anchor
I want to be able to substitute for text in HTML that's matched only
when it doesn't appear in an anchor. For example, given
blah blah foo blah <em>foo</em> blah <a href="foo.html">foo</a> blah blah
I'd want the first and second instances of the word "foo" to match, and
be substituted for, but not the third or fourth (because they're in the
anchor). Notice that foo can be in another element, as with EM in the
example above.
My reason for this requirement is that the substitution I want to do is
to make an occurence of the sought-after string into an anchor,
replacing, for example, 'foo' with '<a href="foo.html">foo</a>'. The
problem is I want to do this in a situation where the program can be run
again and again with the same input text, so I don't want text that's
already been made an anchor to be modified again. (I.e., I don't want
<a href="<a href="foo.html">foo</a>.html"><a href="foo.html">foo</a></a>
the second time through.)
I hope I've made it clear what I'm after. Any help would be appreciated.
--
Cole Robison
Software Training Specialist
Academic Computing Services, The University of Kansas