111,093
社区成员




string a="a:3:{i:0;a:3:{i:0;s:4:\"dfdf\";i:1;s:4:\"dsfg\";i:2;s:4:\"gfgg\";}"
+"i:1;a:3:{i:0;s:3:\"jkj\";i:1;s:2:\"jj\";i:2;s:3:\"ffg\";}"
+"i:2;a:3:{i:0;s:3:\"sdd\";i:1;s:5:\"dfsdf\";i:2;s:4:\"gfgh\";}}";
string[] str1 = System.Text.RegularExpressions.Regex.Split(a.Substring(0,a.Length-3), ";}");
Console.WriteLine(str1.Length);//这里就可以得出有几组数据。
//如string[][] t = new string[3][];
foreach (string i in str1)
{
string tmp = "\"" + i;
string[] str2 = System.Text.RegularExpressions.Regex.Split(tmp, "\"[^\"]*\"");
int l2 = str2.Length;
foreach (string j in str2)
{
Console.WriteLine(j); //输出多了一个空字符串,你可以处理一下
}
}
string a=":{i:0;a:3:{i:0;s:4:\"dfdf\";i:1;s:4:\"dsfg\";i:2;s:4:\"gfgg\";}";
while (a.IndexOf("\"")!=-1)
{
a = a.Substring(a.IndexOf("\""));
int i = a.IndexOf("\"",1);
string b = a.Substring(1, i - 1);
Console.WriteLine(b);//这就是想要的吧?
a = a.Substring(i+1);
}