Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

VS 2010 [RESOLVED] Help with extracting a team name from a line of text

$
0
0
I wrote a program that extracts information from posted track and field results. Here is an example:
Event 10 55 Meter Hurdles 11-12 Division Boys
=========================================================================
Name Year Team Prelims Finals
=========================================================================
Finals
1 Parson, Jessie I5 Elite 9.13 9.49
2 Sampson, Zachary Unattached 11.10 9.53
3 Drewery, Chase Fasst Track 10.37 9.66
4 Trinh, Ty Woodlawn Tra 10.50 9.75
5 von Chatmon, Keith Woodlawn Tra 11.00 10.78
6 Barley Jr., Charles Sofcc Warrio 10.00 11.16


My Attempt:

Sub test2()
Dim str As String
Dim arrTmp() As String
str = "1 Parson, Jessie I5 Elite 9.13 9.49"
arrTmp = Split(RemoveDoubleSpace(str), " ")
End Sub

Public Function RemoveDoubleSpace(MyString As Variant) As String
MyString = Trim(MyString)
Do While InStr(MyString, " ")
MyString = Replace(MyString, " ", " ")
Loop
RemoveDoubleSpace = MyString
End Function

This returns:
0: 1
1: Parson
2: Jessie
3: i5
4: Elite
5: 9.13
6 9.49

I want to extract "i5 Elite". For this case, I know to extract 3 &4 but the length of the team name is not known in advance. One suggestion is to determine the location of the first numerical value after the name in element (2) in hopes to get the location of 9:13 but as you can see from this example, the 5 in i5 will present a problem.

I currently use regular expressions to extract the numerical values. I could not determine a pattern to reliably extract the team name.
I would like to make this as general as possible.

Thank you.

Viewing all articles
Browse latest Browse all 42215

Trending Articles