开发者

Modify regex code, only one line

I have this code

Dim parts As New List(Of String)(Regex.Split(RichTextBox2.Text, "~\d"))

开发者_JAVA技巧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.Split you could use Regex.Matches with the regular expression "\w+".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜