Reputation: 573
I am trying to get each sentence from my rtextbox
into an array. However, when I use .split
method, it gives me empty spaces as part of the array.
How can I either remove the empty ones or not have them come into the array in the first place?
Dim senArray() = RTextBox.Text.Split(New String() {"."}, StringSplitOptions.RemoveEmptyEntries)
Thank you!
Upvotes: 1
Views: 11057
Reputation: 32202
You can use a linq Where
expression to remove the whitespace entries:
Dim senArray() = RTextBox.Text.Split(
New String() {"."}, StringSplitOptions.RemoveEmptyEntries
).Where(
Function(s) Not String.IsNullOrWhitespace(s)
).ToArray()
Upvotes: 9