Use find() to locate the starting position of "Visitor Sessions".
Add the number of characters from the "V" in "Visitor" to the first
digit of the actual number. This length should be a constant as its just
a few html tags building the table. Now that you have the start position
of the number, you want to run a loop for each character, checking to
see if its numeric or not. Once you find a character that isn't a
number, break the loop. The index now holds the length in characters of
the data.
<!---- get start position ---->
<cfset cursorInt = find("Visitor Sessions", textFile) + constantLength>
<!---- trim the original text file ---->
<cfset textFile = right(textFile, evaluate(len(textFile)-cursorInt))>
<!---- check each character ---->
<cfloop from="1" to="len(textFile)" index="cursorIndex">
<cfif NOT isNumeric(mid(textFile, cursorIndex, 1))>
<cfbreak>
</cfif>
</cfloop>
<!---- assign final data ---->
<cfset visitorSession = left(textFile, cursorIndex)>
Here is one way to do it. Hope it helps. If you have to do this for
multiple data on a page, turn it into a customTag that takes the three
attributes:
<cf_webTrendData label="Visitor Sessions" constantLength="40"
varName="visitorSession">
You could parse out HTML tags, but that will be a little more processor
intensive. Not to mention a pain in the arse.
Enjoy.
Adam Wayne Lehman
Web Systems Developer
Johns Hopkins Bloomberg School of Public Health
Distance Education Division
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:hecgam@;attbi.com]
Sent: Tuesday, October 22, 2002 4:21 PM
To: [EMAIL PROTECTED]
Subject: RE: Reg Ex help (fwd)
the html is from a webtrends report. i have no say how
it's formatted! haha
i cut out some of the code before visitor sessions,
that's why the code may look funny.
basically it's:
visitor sessions #
Average Session #
ect....
---------------------- Forwarded Message: ---------------------
From: "Adrocknaphobia Jones" <[EMAIL PROTECTED]>
To: CF-Talk <[EMAIL PROTECTED]>
Subject: RE: Reg Ex help
Date: Tue, 22 Oct 2002 16:14:58 -0400
Hey. The <font> tag is deprecated. Since the 90s. :-\
Why does the table have "Visitor Sessions" in two columns next to each
other? Is the code correct?
Adam Wayne Lehman
Web Systems Developer
Johns Hopkins Bloomberg School of Public Health
Distance Education Division
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:hecgam@;attbi.com]
Sent: Tuesday, October 22, 2002 4:02 PM
To: CF-Talk
Subject: Reg Ex help
Hello - i'm new to the forum. I am just learning
regular expressions and need some help!
i am using cffile to read a file and output a number to
another page using refindnocase to parse the data.
here's the data i want to parse:
<TR BGCOLOR="FFFFFF">
<TD rowspan=6 valign=top ALIGN ="LEFT" width='30%'>
<FONT SIZE=1 FACE="ms sans
serif,arial,helvetica,verdana,lucida,utopia"
COLOR="000000"><B>Visitor Sessions</B></FONT></TD>
<TD ALIGN ="LEFT" >
<FONT SIZE=1 FACE="ms sans
serif,arial,helvetica,verdana,lucida,utopia"
COLOR="000000">Visitor Sessions</FONT></TD>
<TD ALIGN ="RIGHT" >
<FONT SIZE=1 FACE="ms sans
serif,arial,helvetica,verdana,lucida,utopia"
COLOR="000000">176,308</FONT></TD>
</TR>
<TR BGCOLOR="FFFFFF">
<TD ALIGN ="LEFT" >
<FONT SIZE=1 FACE="ms sans
serif,arial,helvetica,verdana,lucida,utopia"
COLOR="000000">Average Per Day</FONT></TD>
<TD ALIGN ="RIGHT" >
<FONT SIZE=1 FACE="ms sans
serif,arial,helvetica,verdana,lucida,utopia"
COLOR="000000">5,687</FONT></TD>
</TR>
This code where the number is located is repeated for
each different subject. I need help to get the Visitor
Session number using a regular expression. And then get
the Average Session length (but i can do that by just
changing the code from Visitor session).
Probably need to start from the >visitor
Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm