I want to develop a highlight function of search terms. The following works
well except that it changes the case of the keyword in the output. For
example, 'Cold' in the original becomes 'cold' in the output.

What can I include in the code to keep the original case of the String? If I
use REReplace() then I omit the keywords because of case sensitivity.

Sebastian

-----------------------------


<cfset String = 'Cold Fusion is a rapid application development system for
professional  developers who want to create dynamic Web applications and
interactive Web sites. It provides the fastest way to integrate browser,
server, and database technologies into powerful Web applications. With Cold
Fusion, you can build everything from online stores to sophisticated
business systems.'>

<!--- Set the highlight style --->
<style type="text/css">
..highlight { background-color: yellow }
</style>

<cfset Keywords = 'cold,web,server'>
<cfset OpenTag = '<span class="highlight">'>
<cfset CloseTag = '</span>'>


<cfloop index="x" from="1" to="#ListLen(Keywords)#">

<cfset HighlightedWord = OpenTag & ListGetAt(Keywords, x)  & CloseTag>

<cfset String= REReplaceNoCase(String, ListGetAt(Keywords, x),
HighlightedWord, "ALL")>

</cfloop> 

<cfoutput>#String#</cfoutput>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to