110,536
社区成员
发帖
与我相关
我的任务
分享
请问如何分别把/中的内容截取出来呀
string s = "abcde/fghighl/mnopqrs/tuvwxyz";
string[] b = s.Split('/');
string d = b[0];
d输出来就是你要的结果
如果你想使用动态的,就for循环,看有多少个/,然后截取你想要的部分就可以了
string str = "abcde/fghighl/mnopqrs/tuvwxyz";
string result = str.Substring(0, str.IndexOf('/'));
string tempStr = Regex.Match("abcde/fghighl/mnopqrs/tuvwxyz", @"[^/]+").Value;//abcde
string str = "abcde/fghighl/mnopqrs/tuvwxyz";
int i = str.IndexOf('/');
MessageBox.Show(str.Substring(0, i));