16,717
社区成员
发帖
与我相关
我的任务
分享 Dim str As String = "asdfasdfa-sdf"
Dim a As String() = str.Split("-")
MsgBox(Mid(str, 1, Len(str) - Len(a(a.Length - 1)) - 1)) string str = "abc-1-2";
int n = str.LastIndexOf('-');
string s = str.Substring(0, n);
MessageBox.Show(s);
呵呵,不好意思给出了C#代码。但关键是使用LastIndexOf方法。