I have this code
Dim parts As New List(Of String)(Regex.Split(RichTextBox2.Text, "~\d"))
That splits lines in this format into parts:
~1Hello~2~3Bye~4~5Morning~6
So if I do MsgBox(parts(5)), it will show me “Morning”.
I want to do the exact same thing, but now my line is arranged like this:
Hello, Bye, Morning,
Change
"~\d"to", ?". The question mark after the space means that the space is optional.Alternatively, assuming that you are only looking for single words, instead of
Regex.Splityou could useRegex.Matcheswith the regular expression"\w+".