>I have been using REReplace to find key words or group of words within
>paragraphs and if found to replace those with an HREF.


The following code works.
(I haven't yet decided whether it's entirely the best way though...)


<cfset Content = ListToArray(Content,'>')/>

<cfloop index="i" from="1" to="#ArrayLen(Content)#">
        <cfif ListLen(Content[i],'<') GT 1>
                <cfset Segment =  ListFirst(Content[i],'<')/>
                <cfset word = "sub"/>

                <cfset Segment = linkifyText( Segment , Word , 
'Display.cfm?Term='&UrlEncodedFormat(Word) ) />

                <cfset Content[i] = Segment & '<' & ListRest(Content[i],'<')/>
        </cfif>
</cfloop>

<cfset Content = ArrayToList(Content,'>')/>



<cffunction name="linkifyText" returntype="String" output="false">
        <cfargument name="Text"   type="String"/>
        <cfargument name="Word"   type="String"/>
        <cfargument name="Target" type="String"/>

        <cfreturn rereplace(Arguments.Text,'\b#Arguments.Word#\b','<a 
href="#Arguments.Target#">\0</a>','all')/>
</cffunction>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314914
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to