从字符串中删除文本直到“-”
Remove text from string until "-"
我正在尝试从字符串中提取文本。此构建字符串的示例可以是:
28/10/2020 21:21:50 Mattia - Stunning Siphonophore - Nautilus Live
我希望能够只提取:“Stunning Siphonophore - Nautilus Live”
如您所见,label1.text 也可以包含“-”,因此我想提取从第一个到最后的所有内容。
我正在尝试:
Dim str = "28/10/2020 21:21:50 Mattia - Stunning Siphonophore - Nautilus Live"
Dim x = "-"
Dim index = str.IndexOf(x)
If (index >= 0) Then
str = str.Substring(0, index)
End If
MessageBox.Show(str)
但这与我想要的完全相反..
谢谢
不清楚 -
之后是否总是有 space,但假设它是可选的,这应该适合您:
Dim str = "28/10/2020 21:21:50 Mattia - Stunning Siphonophore - Nautilus Live"
Dim x = "-"
Dim index = str.IndexOf(x)
If (index >= 0) Then
str = str.Substring(index + 1).Trim()
End If
我正在尝试从字符串中提取文本。此构建字符串的示例可以是:
28/10/2020 21:21:50 Mattia - Stunning Siphonophore - Nautilus Live
我希望能够只提取:“Stunning Siphonophore - Nautilus Live” 如您所见,label1.text 也可以包含“-”,因此我想提取从第一个到最后的所有内容。 我正在尝试:
Dim str = "28/10/2020 21:21:50 Mattia - Stunning Siphonophore - Nautilus Live"
Dim x = "-"
Dim index = str.IndexOf(x)
If (index >= 0) Then
str = str.Substring(0, index)
End If
MessageBox.Show(str)
但这与我想要的完全相反.. 谢谢
不清楚 -
之后是否总是有 space,但假设它是可选的,这应该适合您:
Dim str = "28/10/2020 21:21:50 Mattia - Stunning Siphonophore - Nautilus Live"
Dim x = "-"
Dim index = str.IndexOf(x)
If (index >= 0) Then
str = str.Substring(index + 1).Trim()
End If