I can't belive that I, of all people, missed a chance to use a regex. I bow my head in shame.
This just goes to show that expanding your mind is a bad thing. Back to the straigt and narrowminded for me. The only thing that I would do differently is add apostrophes, hyphens, and underscores to the allowed characters and replace multiple spaces with a single pipe to avoid issues there: terms = REReplaceNoCase(terms, "[^a-z_-]+"," ","All"); terms = Replace(terms, " +","|","All"); -- Ben Doom Programmer & General Lackey Moonbow Software, Inc : -----Original Message----- : From: Jochem van Dieten [mailto:[EMAIL PROTECTED]] : Sent: Monday, February 17, 2003 4:54 PM : To: CF-Talk : Subject: Re: highlight MULTIPLE keywords in search results... : : : Tuan wrote: : > Can somebody provide me with an example of how to highlight : multiple keywords in a search result? For example say I wanted to : search for "macromedia coldfusion, studio" the search results : will highlight every instance of "macromedia", "coldfusion", and : "studio" in the document. : : 2 step process. First clean up yuor search string, probably best done by : replacing all non-alphabetic characters with spaces, then dumping all : the 1 char searchstrings (presuming English). The run a replace with : what is left (no loop necessary if you use a regex). Pseudocode: : : //cleanup: : terms = REReplaceNoCase(terms, "[^a-z]+"," ","All"); : terms = REReplaceNoCase(terms, "^[a-z] | [a-z] | [a-z]$"," ","All"); : : //highlight : terms = Replace(terms, " ","|","All"); : text = REReplaceNoCase(text,"(#terms#)","<em>\1</em>","All"); : : Jochem : : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4