A while back, I built a simple cms system for an article-based site where some of the articles have links and email addresses built in. My client wanted to be able to simply copy and paste the articles into the textarea, and not have to fuss with making each of the links. (that, and I really didn't want to turn her loose with fckeditor in this case... 'just the facts, ma'am")
So, I jumped over to experts-exchange, and within minutes of posting my question, one of the legions of experts in the ColdFusion arena gave me this nice bit of regular expressionism, wrapped up in a nice little function (ok, two functions)
It will find anything starting with http://, www., or http://www, and turn it into a link. Anything in email format ( something@something.something) gets made into a mailto: link.
========================
<!--- This function creates hyper links from url strings,
and email mailTo links from email addresses --->
<cffunction name="LinkURLs" output="true" returntype="string">
<cfargument name="text" type="string" required="yes">
<!--- Define local variables --->
<cfset var pos=1>
<cfset var subex="">
<cfset var done=false>
<cfset results = arguments.text>
<cfloop condition="not done">
<!--- Perform search --->
<cfset subex=reFind("(http://|http://www|www)(.*?)([[:space:]]|$)", arguments.text, pos, true)>
<!--- Anything matched? --->
<cfif subex.len[1] is 0>
<cfset done=true>
<cfelse>
<cfsavecontent variable="theLink"><a href="http://#replace(mid(text,subex.pos[1],subex.len[1]),'http://','')#">#mid(text,subex.pos[1],subex.len[1])#</a></cfsavecontent>
<cfset results = replace(results,mid(text,subex.pos[1],subex.len[1]),theLink)>
<!--- Reposition start point --->
<cfset pos=subex.pos[1]+subex.len[1]>
</cfif>
</cfloop>
<!--- and return results --->
<cfreturn results>
</cffunction>
<cffunction name="LinkEmails" output="true" returntype="string">
<cfargument name="text" type="string" required="yes">
<!--- Define local variables --->
<cfset var pos=1>
<cfset var subex="">
<cfset var done=false>
<cfset results = arguments.text>
<cfloop condition="not done">
<!--- Perform search --->
<cfset subex=reFind("([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})", arguments.text, pos, true)>
<!--- Anything matched? --->
<cfif subex.len[1] is 0>
<cfset done=true>
<cfelse>
<cfsavecontent variable="theLink"><a href="mailto:#mid(text,subex.pos[1],subex.len[1])#">#mid(text,subex.pos[1],subex.len[1])#</a></cfsavecontent>
<cfset results = replace(results,mid(text,subex.pos[1],subex.len[1]),theLink)>
<!--- Reposition start point --->
<cfset pos=subex.pos[1]+subex.len[1]>
</cfif>
</cfloop>
<!--- and return results --->
<cfreturn results>
</cffunction>
===================
To call the function, I simply used
#linkEmails(linkUrls(recordDescrip))#
where #recordDescrip# is my article text
easy, eh?