我希望将字符串拆分为某些部分。这就是我想要的样子:
Original String : /abc/def/ghi
String1 : /abc
String2 : /abc/def
String3: /abc/def/ghi
预先感谢
string uri = "/abc/def/ghi";
string regex_text_dummy = Uri;
Regex first_part_regex = new Regex("^/.*/$");
path_stack[0] = Regex.Match(regex_test_dummy, first_part_regex);
答案 0 :(得分:2)
string Original_str = "/abc/def/ghi/ass/ddf/fgfg";
string[] arr=Original_str.Split('/');
string str="";
for (int x = 0; x < arr.Length - 1; x++)
{
str += arr[x] +"/";
Console.WriteLine(str);
}