Text Replace function

M

Mark Tait

Hi - I'm using the replace function to hilite search words in text which
is returned. However, as the text which is being searched also includes
HTML, I find sometimes that the HTML tags can be replaced, which in turn
messes up the text which is dieplayed.

Is there any way of checking only text which does not appear between <>
tags?

eg.

myText="<img src='bob.gif'>bob"
mySearch="bob"

replace(myText,mySearch,"<b>" & mySearch & "</b>")

...this will end up:

myText="<img src='<b>bob</b>.gif'><b>bob</b>"

Has anyone any ideas?

Many thanks,


Mark Tait
(e-mail address removed)
www.fixitks.co.uk
Knowledge Management Solutions
 
E

Evertjan.

Mark Tait wrote on 03 jul 2003 in
microsoft.public.inetserver.asp.general:
Hi - I'm using the replace function to hilite search words in text
which is returned. However, as the text which is being searched also
includes HTML, I find sometimes that the HTML tags can be replaced,
which in turn messes up the text which is dieplayed.

Is there any way of checking only text which does not appear between
<> tags?

eg.

myText="<img src='bob.gif'>bob"
mySearch="bob"

replace(myText,mySearch,"<b>" & mySearch & "</b>")

..this will end up:

myText="<img src='<b>bob</b>.gif'><b>bob</b>"

Has anyone any ideas?

This replace is not a good idea.

do something with:

txt.select();

like in:

<http://www.javascripter.net/faq/searchin.htm>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top