Wow, now this is too much of a coincidence. I just opened up my email
program to post a message saying I had just successfully written a program
that parses url's out of a document, and was just wondering if anyone had a
better way to do it. Well here is how I did it.
If anyone knows of a faster way I am definately interested. I imagine
regular expressions would be much faster...
Cfscripting this would most likely make it faster too, but for readability I
am leaving it in regular cfml for now.
jon
**Read html file, you can replace h with your variable
<cffile action="READ" file="c:\www\test\html.htm" variable="h">
**Stick the entire file in an array
<cfset arrString = ArrayNew(1)>
<cfset rs = ArrayResize(arrString,len(h))>
<cfloop from="1" to="#len(h)#" index="i">
<cfset arrString[i] = mid (h,i,1)>
</cfloop>
**Loop through array looking for tags, and mark their positions
<cfset markArray = ArrayNew(1)>
<cfloop from="1" to="#arrayLen(arrString)#" index="i">
<cfif arrString[i] EQ "<">
<cfset rs = ArrayAppend(markArray,i)>
</cfif>
<cfif arrString[i] EQ ">">
<cfset rs = ArrayAppend(markArray,i)>
</cfif>
</cfloop>
**Loop through the array of marks looking for links.
**I replace the < with < just so I can display it.
<cfloop index="i" from="1" to="#arrayLen(markArray)#" step="2">
<cfset linklen = markArray[i + 1] - markArray[i]>
<cfif mid(h,markArray[i],2) EQ "<a">
<cfoutput>
#replace(mid(h,markArray[i],linklen),"<","<","ALL")#<br>
</cfoutput>
</cfif>
</cfloop>
----- Original Message -----
From: "W Luke" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, June 02, 2001 4:38 PM
Subject: REFindnocase
> Hi,
>
> I need to search for any URLs that exist in #tbody# and if so, dump the
> whole URL into a new variable called #user_URL#
>
> I've done a basic REfindnocase to check if there is a URL in the string,
but
> that only finds the position(s). Hw can I then grab the whole of the URL?
>
> <Cfset z = #REfindnocase("www.", #tbody#)#>
>
> If z returns greater then 0 then continue to get the rest of the URL,
> otherwise ignore.
>
> Any guidance would be appreciated.
>
> Will
>
> --
> Will
> Free Advertising-=- www.localbounty.com
> e: [EMAIL PROTECTED] icq: 31099745
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists