If you just need a regex replace that is a bit more
straightforward.
<cfscript>
regex = "(http:/.*?) ";
string = "The quick brown
http://www.fox.com jumped over the
http://www.lazy.net dog.";
newString = reReplaceNoCase(string,regex,'<a
href="\1">\1</a>',"ALL");
</cfscript>
For fun, I played with this a bit and here is some code that
demonstrates both a search and find, and the above simple
replace. You
will probably want to expand the regex to include instances
where the
link is not in the middle of a sentence and thus is followed
by
something other then a space such as a period.
<cfscript>
regex = "(http:/.*?) ";
string = "The quick brown
http://www.fox.com jumped over the
http://www.lazy.net dog.";
//LOGIC TO FIND EACH INSTANCE.
links = arrayNew(1);
start = 1;
link = reFindNoCase(regex,string,start,true);
while (link.pos[1] NEQ 0) {
arrayAppend(links,mid(string,link.pos[1],link.len[1]));
start = link.pos[1] + link.len[1];
link = refindnocase(regex,string,start,true);
}
//LOGIC TO REPLACE EACH INSTANCE.
newString = reReplaceNoCase(string,regex,'<a
href="\1">\1</a>',"ALL");
</cfscript>
<cfdump var="#links#">
<hr />
<cfoutput>#htmlCodeFormat(newString)#</cfoutput>