I have a string which is a part of a text file. I need to extract data related to each item.
The string is:
GRID "G1 Global" LABEL "A 2 3" DIR "X-1" COORD 0 VISIBLE "Yes"
I used Split by "space" and "quotation marks" but the the resulats was not as I expected. I need to assign data to each item. For example "G1 Global" for GRID and 0 for COORD.
I used tis code for extract each word from the string:
Dim linestring As Object
Dim word0 As String
Dim i As Integer
Dim goalstring As String = TextBox2.Text 'Thextbox2.text = GRID "G1 Global" LABEL "A 2 3" DIR "X-1" COORD 0 VISIBLE "Yes"
'linestring = Split(goalstring, """")
linestring = Split(goalstring, " ")
For Each word0 In linestring
If word0 <> "" Then
i += 1
Console.WriteLine(i & ":" & word0)
End If
Next
The expected result is:
1:GRID
2:G1 Global
3:LABEL
4:A 2 3
5:DIR
6:X-1
7:COORD
8:0
9:VISIBLE
10:"Yes"
But I get this by Split(goalstring, " "):
1:GRID
2:"G1
3:Global"
4:LABEL
5:"A
6:2
7:3"
8:DIR
9:"X-1"
10:COORD
11:0
12:VISIBLE
13:"Yes"
and this by Split(goalstring, """"):
1: GRID
2:G1 Global
3: LABEL
4:A 2 3
5: DIR
6:X-1
7: COORD 0 VISIBLE
8:Yes