【发布时间】:2011-04-20 12:43:11
【问题描述】:
如何选择从特定字符数开始的字符串的最后一部分。 例如,我想获取第三个逗号之后的所有文本。但我收到一条错误消息 "StartIndex 不能小于零。"
Dim testString As String = "part, description, order, get this text, and this text"
Dim result As String = ""
result = testString.Substring(testString.IndexOf(",", 0, 3))
【问题讨论】:
-
您想要在 第三个 逗号之后的文本,还是在 最后一个 逗号之后(在您给定的示例中恰好是相同的)?如果您输入
"One, two, three, four, five and six",您的预期结果是什么?"four, five and six"或"five and six"? -
是第三个逗号后。我想把第四个放在那里,为了清楚起见,我对其进行了编辑。