Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27518

VS 2010 [RESOLVED] Keep whitespace in split

$
0
0
I'm working on a project where I need to iterate through all the words in a string, but I also need to keep whitespace as that is important to what I need. For example, currently this is happening:
Code:

Dim line As String = "the quick brown fox jumps over the lazy dog"
For y As Integer = 0 To line.Split({" "}, StringSplitOptions.None).Count - 1
    Console.WriteLine(line.Split({" "}, StringSplitOptions.None)(y))
Next

'Result
'-------
'the
'quick
'brown
'fox
'jumps
'over
'the
'lazy
'dog

What I need is for the results to look like this:
Code:

'Result
'-------
'the
'
'quick
'
'brown
'
'fox
'
'jumps
'
'over
'
'the
'
'lazy
'
'dog

What should I do?!

Viewing all articles
Browse latest Browse all 27518

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>