I am trying to figure out a way to markup text results that have a search term
in it (see: Google, Yahoo, etc). The problem I'm having with the replacenocase
function is that the original text loses its case...which I don't want.
For example...
If someone searches for the keyword "coldfusion" and the following text is as
follows...
Original Text
1. ColdFusion Tutorial
With Markup
1. [B]coldfusion[/B] Tutorial
Since the user typed in lower case coldfusion...I lose the case when doing a
replacenocase function.
Any way around this without having to do a replace with every possible case
combination?
<cfset title = replacenocase(title,session.q,"<strong>#session.q#</strong>")>
Azadi - 28 Feb 2008 12:34 GMT
i have seen jquery plugins that do that, for sure, and possible a udf at
cflib.org
yep, here: http://cflib.org/udf.cfm?ID=133
and maybe this one can help, too: http://cflib.org/udf.cfm?ID=721
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
mrgccc3 - 29 Feb 2008 01:44 GMT
Hey so this works, no case ever changes:
<cfset text = "[B]Coldfusion[/B] Tutorial" >
<cfset newtext = rereplacenocase(text,"\[B\](.*?)\[/B\]","<strong>\1</
strong>","all")>
<cfdump var="#newtext#">
<cfoutput>#newtext#</cfoutput>
You could always loop through this and change B to whatever you need
it to be in the rereplacenocase function.
Enjoy