If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Array and Regular Expression problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-28-04, 11:49
lrosenhan lrosenhan is offline
Registered User
 
Join Date: May 2004
Posts: 2
Array and Regular Expression problem

I am pulling bus routes from a database by bus number and then pulling the stop times from each run. I then pull the first and last times from those arrays.

This works fine, and will display the full routes:

<%
Routes = Array(Rs("Route1"), Rs("Route2"), Rs("Route3"))
For Each Route in Routes
%>
<%=Route%><br />
<%
Next
%>

This also works fine, and will deliver the first and last time from one route:

Route = Rs("Route2")
Times = Trim(RegExpTest("(\s|(\s\d))\d:\d\d\s", Route))
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches, RetStr
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(strng)
For Each Match in Matches
RetStr = RetStr & " " & Trim(Match.Value) & " "
Next
RegExpTest = RetStr
End Function
First = Trim(Left(Times,5))
Last = Trim(Right(Times,5))
%>
<%=First%>
<%=Last%>


But combining the two fails. I haven't figured out why. Error message is
a vbscript syntax error.


Routes = Array(Rs("Route1"), Rs("Route2"), Rs("Route3"))
For Each Route in Routes
Times = Trim(RegExpTest("(\s|(\s\d))\d:\d\d\s", Route.Value))
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches, RetStr
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(strng)
For Each Match in Matches
RetStr = RetStr & " " & Trim(Match.Value) & " "
Next
RegExpTest = RetStr
End Function
First = Trim(Left(Times,5))
Last = Trim(Right(Times,5))
%>
<%=First%>
<%=Last%>
<% Next %>

Any help would be deeply appreciated.

Lee
Reply With Quote
  #2 (permalink)  
Old 05-28-04, 20:48
lrosenhan lrosenhan is offline
Registered User
 
Join Date: May 2004
Posts: 2
How dumb can I be?

Why is the function inside the loop? Good question. As soon as I moved it outside the loop where it belongs, everything worked just fine.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On