You can use regular expressions to get this to work; you'll want to read up
on the RegExp object.   You can then define your regular expression in such
a way that you "ignore" text within <> characters.  Also, make sure you
consider case-sensitivity (should you also highlight "Image"?).  The RegExp
object has a property called IgnoreCase to deal with this.

And, what if "image" is found within another word?  For example, should
"primage" match? (Yes, this is a word).

Anyway, the tricky bit is getting your regular expression right.  Once you
do that, you can just use the Replace property of the RegExp object.

-Dave


-----Original Message-----
From: Thomas V. Nielsen [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 19, 2002 2:39 AM
To: ActiveServerPages
Subject: RE: Google Highlight


The problem lies in, if you search for at term like "image", then the simple
replace would mess up a line like:

<img scr="./image/picture.jpg">This is a nice image of something..

Would turn into

<img scr="./<span style="background:#FF0000">image</span>/picture.jpg">This
is a nice <span style="background:#FF0000">image</span> of something..

And that doesn't look nice in any browser..

<thomas/>


> -----Original Message-----
> From: Chris Tifer [mailto:[EMAIL PROTECTED]]
> Sent: 16. august 2002 22:49
> To: ActiveServerPages
> Subject: Re: Google Highlight
>
>
> If you have the text that's going to be output, replace matching
> terms like such (this is VERY simple - it doesn't take into account
> the fact that the term may appear inside a link, etc):
>
> strText = "your text that will be output"
>
> Response.Write REPLACE(strText, "your", "<span style=""background:
> #FF0000'"">your</span>")
>
> Of course, you'd make the word "your" dynamic and probably
> wouldn't choose
> such an ugly bg color, but you get the point...
>
> Chris Tifer
> http://www.emailajoke.com
>
>
> ----- Original Message -----
> From: "Thomas V. Nielsen" <[EMAIL PROTECTED]>
> To: "ActiveServerPages" <[EMAIL PROTECTED]>
> Sent: Friday, August 16, 2002 10:26 AM
> Subject: Google Highlight
>
>
> > Sory for the perhaps OT here, but I have failed to accomplish this
> > serverside.
> >
> > Anyone who use the Google toolbar for IE knows, when you
> hit the button
> > "Highlight" the words you have searched for, is getting
> highlighted and
> > easy to spot.
> >
> > You kan do a bit by the same by presseing CTRL+F, which you
> could trick
> > client-side by some javascript.
> >
> > But how can I do something similar - that is to highligt
> some text on a
> > webpage?
> >
> > </thomas>
> >

---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%


---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to