串和特定字符后返回值(substring and return the value after a

2019-07-30 01:38发布

“Testing.BSMain,文本:起始页”

我想以上的子字符串值和回国后我才有价值“:”在vb.net。 我怎样才能做到这一点?

Answer 1:

假设没有错误检查:

Dim phrase As String = "Testing.BSMain, Text: Start Page".Split(":")(1)

它简单地由结肠将短语拆分并返回的第二部分。

要使用串,试试这个:

Dim test As String = "Testing.BSMain, Text: Start Page"
Dim phrase As String = test.Substring(test.IndexOf(":"c) + 1)


Answer 2:

你可以使用split方法冒号后返回值

   Dim word as String  = "Testing.BSMain, Text: Start Page"
   Dim wordArr as String()  = word.Split(":")
   Dim result as String = wordArr(1);


文章来源: substring and return the value after a specific character