Reputation: 1396
I am very new to Vb.net, and have found out how to split strings and put the remnants of the split string in an array like so...
Dim str As String
Dim strArr() As String
Dim count As Integer
str = "vb.net split test"
strArr = str.Split(" ")
For count = 0 To strArr.Length - 1
MsgBox(strArr(count))
Next
Output:
vb.net
split
test
Now that I've got that figured out, I was wondering if there was a way to split on the SECOND space giving the output...
vb.net split
test
Thanks for your time!
Upvotes: 0
Views: 844
Reputation: 216293
You can do something like this
Dim input = "This is a Long String"
Dim splitted = input.Split(" "c)
Dim result = New List(Of String)()
For x As Integer = 0 To splitted.Length - 1 Step 2
result.Add(String.Join(" ", splitted.Skip(x).Take(2)))
Next
Upvotes: 2