Here is one by Lucas Sherwood, [EMAIL PROTECTED] & author Joel Mueller
([EMAIL PROTECTED])
ActivateURL think it might be on cflib.org
Justin
<cfscript>
/**
* This function takes URLs in a text string and turns them into links.
* Version 1 by Lucas Sherwood, [EMAIL PROTECTED]
*
* @param string Text to parse. (Required)
* @param target Optional target for links. Defaults to "". (Optional)
* @param paragraph Optionally add paragraphFormat to returned string.
(Optional)
* @return Returns a string.
* @author Joel Mueller ([EMAIL PROTECTED])
* @version 2, October 11, 2002
*/
function ActivateURL(string) {
var nextMatch = 1;
var objMatch = "";
var outstring = "";
var thisURL = "";
var thisLink = "";
var target = IIf(arrayLen(arguments) gte 2, "arguments[2]", DE(""));
var paragraph = IIf(arrayLen(arguments) gte 3, "arguments[3]",
DE("false"));
do {
objMatch =
REFindNoCase("(((https?:|ftp:|gopher:)\/\/)|(www\.|ftp\.))[-[:alnum:]\?%,\.\
/&##!@:=\+~_]+[A-Za-z0-9\/]", string, nextMatch, true);
if (objMatch.pos[1] GT nextMatch OR objMatch.pos[1] EQ nextMatch) {
outString = outString & Mid(String, nextMatch, objMatch.pos[1]
-
nextMatch);
} else {
outString = outString & Mid(String, nextMatch, Len(string));
}
nextMatch = objMatch.pos[1] + objMatch.len[1];
if (ArrayLen(objMatch.pos) GT 1) {
// If the preceding character is an @, assume this is an
e-mail address
// (for addresses like [EMAIL PROTECTED])
if (Compare(Mid(String, Max(objMatch.pos[1] - 1, 1), 1), "@")
NEQ 0) {
thisURL = Mid(String, objMatch.pos[1],
objMatch.len[1]);
thisLink = "<a href=""";
switch (LCase(Mid(String, objMatch.pos[2],
objMatch.len[2]))) {
case "www.": {
thisLink = thisLink & "http://";
break;
}
case "ftp.": {
thisLink = thisLink & "ftp://";
break;
}
}
thisLink = thisLink & thisURL & """";
if (Len(Target) GT 0) {
thisLink = thisLink & " TARGET=""" & Target &
"""";
}
thisLink = thisLink & ">" & thisURL & "</a>";
outString = outString & thisLink;
// String = Replace(String, thisURL, thisLink);
// nextMatch = nextMatch + Len(thisURL);
} else {
outString = outString & Mid(String, objMatch.pos[1],
objMatch.len[1]);
}
}
} while (nextMatch GT 0);
// Now turn e-mail addresses into mailto: links.
outString = REReplace(outString,
"([[:alnum:]_\.\-]+@([[:alnum:]_\.\-]+\.)+[[:alpha:]]{2,4})", "<a
href=""mailto:\1"">\1</a>", "ALL");
if (paragraph) {
outString = ParagraphFormat(outString);
}
return outString;
}
</cfscript>
-----Original Message-----
From: Aidan Whitehall [mailto:[EMAIL PROTECTED]
Sent: 12 March 2004 16:45
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] CFML for converting e-mail addys and URLs into
hyperlinks
Anyone got a CFX or CFML that takes a string and returns it with e-mail
address and URLs wrapped in <a> tags?
Had a shufty on the Exchange but it's needle in a haystack (must be
searching on the wrong terms).
Ta
--
Aidan Whitehall <mailto:[EMAIL PROTECTED]>
Macromedia ColdFusion Developer
Fairbanks Environmental Ltd +44 (0)1695 51775
Queen's Awards Winner 2003 <http://www.fairbanks.co.uk/go/awards>
Fairbanks uses anti-spam filtering. If you sent an e-mail and expected
to receive a response but didn't, please call -- it may be that your
e-mail didn't make it to the intended mailbox.
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided
by activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by
proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by
gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by
activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]