I have been using this CF_URL tag for a while it does just fine exept it is
really slow. Does anyone have better solution or a way to speed this up?
Thank you

 

Rick Eidson

 

Here is Code

 

 

<CFTRY> 

            <CFSET y = 1>

            <CFLOOP from="1" to="#len(text)#" index="x">

            <!--- This regular expression finds the string www followed by 

                        any number of characters that do NOT contain
whitespace [^ ]* ending with .com --->

<CFSET FoundFQDN = REFindNoCase("(http://)[^
]*(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|1|2|3|4|5|6|7|8|9|0|/
|\\)", "#text#", y, "TRUE")>

             <CFIF FoundFQDN.pos[1] GT 0>

                                    <CFSET GetFQDN = Mid(text,
FoundFQDN.pos[1], FoundFQDN.Len[1])>

                                    <CFIF (FoundFQDN.pos[1] +
FoundFQDN.Len[1]) LT Len(text)>

                                                <CFSET CrFound =
Find("#chr(13)#", GetFQDN)>

                                                <CFIF CrFound EQ 0>

                                                            <CFSET GetFQDN =
Mid(text, FoundFQDN.pos[1], FoundFQDN.Len[1])>

                                                <CFELSE>

                                                            <CFSET GetFQDN =
Mid(text, FoundFQDN.pos[1], CrFound - 1)>

                                                </cfif>

                                                <CFSET CheckNextChar =
(Mid(text, FoundFQDN.pos[1] + FoundFQDN.Len[1] + 1,1))>

                                                <CFIF CheckNextChar EQ "?">

                                                            <CFSET FoundFQDN
= REFindNoCase("(http://)[^ ]*[ ]", "#text#", y, "TRUE")>

                                                </cfif>

                                    </cfif>

 

                                    <CFSET InvalidCharList = ArrayNew(2)>

                                    <CFSET InvalidCharList[1][1] =
"33"><CFSET InvalidCharList[1][2] = "46">

                                    <CFSET InvalidCharList[2][1] =
"58"><CFSET InvalidCharList[2][2] = "64">

                                    <CFSET InvalidCharList[3][1] =
"91"><CFSET InvalidCharList[3][2] = "96">

                                    <CFSET InvalidCharList[4][1] =
"123"><CFSET InvalidCharList[4][2] = "150">

                                    

                                    <CFLOOP from="1" to="4" index="z">

                                                <CFSET RemovedInvalidChar =
"False">

                                                <CFLOOP
from="#InvalidCharList[z][1]#" to="#InvalidCharList[z][2]#" index="x">

                                                            <CFIF
Right(GetFQDN,1) EQ "#Chr(x)#">

 
<CFSET GetFQDN = Left(GetFQDN, (Len(GetFQDN) - 1))>

 
<CFSET RemovedInvalidChar = "True">

 
<CFBREAK>

                                                            </cfif>

                                                </cfloop>

                                    </cfloop>

            

                                    <cfset
LINKTEXT=#ReplaceNoCase(GetFQDN,'http://','')#>

                                    

                                    <CFSET NewFQDN = "<a
href='http://#LINKTEXT#' target='_blank'>#GetFQDN#</a>">

                        

                        

                                    <CFSET y = FoundFQDN.pos[1] +
Len(NewFQDN)>

                                    <CFSET text = Replace(text, GetFQDN,
NewFQDN)>

                        

                        </cfif>                           

            </cfloop>

<cfcatch></cfcatch>

            

</CFTRY>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to