How about this:
As you make each pass, do not change the message, just note the position
of the word to be changed.  When all passes have been done, do one final
pass, changing those words whose position you've recorded.
-David

On Wed, 25 Oct 2000 17:40:37 -0700 "Brent Goldman"
<[EMAIL PROTECTED]> writes:
> Hello,
> 
> I am having the search function of a CF template highlight words 
> that a user
> entered in their query.  For example, if someone searches for "test" 
> in the
> query box, it would then go through and replace the word "test" with 
> a span
> tag with class "highlight" in order to highlight it.  The following 
> code is
> how I did it:
> 
> REReplaceNoCase(threads.message, "(#query#)","<SPAN
> CLASS='highlight'>1</SPAN>", "ALL");
> 
> After implementing this feature, I made it so that the CF template 
> takes all
> the words in the string "query", and makes and array out of it 
> called
> "keywords", with each element of the array being a different word 
> from the
> original string "query."  To make it do that the search/highlighting
> function worked with the new code, I did a CFLOOP of the 
> REReplaceNoCase
> function, each time making the word to change a different element in 
> the
> keyword array.  The only problem was, if someone searched for 
> something with
> the words "span" or "highlight" or any part of those words, the 
> second time
> the loop went around it would replace the things it itself added 
> into the
> message, thus making it so that the highlighting of the first word 
> in the
> keywords array wouldn't work, and would even display partial HTML 
> around it.
> Is there a way to make the REReplaceNoCase function search through a 
> message
> and replace any word that appears in a certain array rather than 
> replacing a
> single word?
> 
> Thanks,
> Brent
________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to