tags:

views:

23

answers:

1

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,
+1  A: 

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.Split you could use Regex.Matches with the regular expression "\w+".

Mark Byers
Thanks Mark, working how it should.
Datadayne