Or a couple loops....

<!--- loop the query and replace the names with markers --->
<cfloop query="artists">
        <cfset thetext = replacenocase(thetext, artist, "**#currentrow#**",
"all") />
</cfloop>

<!--- now loop again and replace the placeholders with their links --->
<cfloop query="artists">
        <cfset thetext = replace(thetext, "**#currentrow#**", "<a
href='mypage.cfm?var=#artist#'>#artist#</a>", "all") />
</cfloop>

That did the trick for me.

-----Original Message-----
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 27, 2007 3:34 PM
To: CF-Talk
Subject: RE: Regex help looking for a name in a string.

I don’t know what I was thinking but that wont work either. Say you had
Bobby and Bobby Hartsfield

If you replaced Bobby Hartsfield with a link then Bobby... the code would
replace the Bobby within Bobby Hartsfield

You will need to order the names by length descending to make sure the
longer names are taken care of first but you will also need to use a regular
expression to replace the strings only if they are NOT within
<a.*?>(#artist#)</a> already


-----Original Message-----
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 27, 2007 3:15 PM
To: CF-Talk
Subject: RE: Regex help looking for a name in a string.

Yes, Do it in your query. Try this...

Select artist
>From tablename
Order by length(artist)


-----Original Message-----
From: Will Swain [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 27, 2007 10:24 AM
To: CF-Talk
Subject: RE: Regex help looking for a name in a string.

Hi Bobby,

Out of interest, how would I reorder by length? In the query? MySQL 4.1.7

Thanks

Will

-----Original Message-----
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] 
Sent: 27 April 2007 13:47
To: CF-Talk
Subject: RE: Regex help looking for a name in a string.

Reorder by length so the longer names come first. Also, I think you only
need replace(works_string, artist, "<a href='profiles.cfm?e=#profileID#'
target='artistWin'>#artist#</a>", "all")









~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by Adobe®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. 
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276435
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