|
-
Nov 16th, 2009, 05:24 AM
#1
Thread Starter
Junior Member
Affecting the next occurrance in a for loop.
Code:
Dim t As String = source
For Each m As System.Text.RegularExpressions.Match In System.Text.RegularExpressions.Regex.Matches(t, ">.*?<")
search = m.Value.Substring(1).Remove(m.Value.Length - 2)
If search = "" Or haku = " " And counter < 337 Then
counter = counter + 1
ElseIf search <> "" And search <> " " And counter > 337 Then
If column = 0 Then
'-------------
If search.Length = 6 Then
length6 = True
Else
length6 = False
End If
'-------------
If length6 = True Then
jump = True
Else
jump = False
End If
'--------------
If jump = False Then
TextBox2.Text = TextBox2.Text & search & " "
counter = counter + 1
column += 1
End If
'--------------
Else
TextBox2.Text = TextBox2.Text & search & ControlChars.CrLf
counter = counter + 1
column -= 1
End If
End If
Next
What you see here, is a code that picks everything written in between > and < markers from a source code on a website. What it returns is always a time stamp in between 00:00 and 23:59 and a string.
Or almost always. There is a few instances where there are two times in a row and not every other, effectively breaking the system.
Also, when this happens, the first time of the two has a "-" after it, i.e 18:00-
What I've been trying to do, is making the program recognize when there is an extra character (the -), delete the extra character, and then jump over the next result in the search (the following time). This would completely resolve the problem.
The thing is, no matter how much I go through it in my head, I can't seem to think of a way to affect the NEXT result without screwing up the current result or all the following results.
As you can see, my code is faulty. What it does now is an emergency method (as my teacher review of the code is coming up real soon) it jumps over the time with the extra character, and lists the following time. This however is not ultimately wanted, because in the bigger scheme of things, it displays the incorrect time for the incorrect string.
Search variable holds all the results of the regex search, for easier handling, and is used for checking for the extra character.
Length6 variable is boolean for determining if the result had the "-" or not.
The column variable is to list the time and the string on the same line in the textbox.
Jump is the variable that makes the code skip the conditioned result from the search.
The counter variable, that might seem extra, is just for extra conditioning, its use is to prevent the first 337 instances of the search.
Thanks a bunch in advance for anyone willing to throw around some ideas. For the sake of saving precious time, please try to say it in code as I am a beginner and there are so much commands and the like I don't know how to use and what they do.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|