Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / February 2008



Tip: Looking for answers? Try searching our database.

Difficult Keyword Replace Function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jimpollard - 28 Feb 2008 12:09 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.