日期:2014-05-18  浏览次数:20687 次

字符串分割问题
string s="1:value:sssname:sdsfftext:sdfsdf1:value:ddddddname:sdfsfdsftext:sdfsfsf";
大致就是截取出来这么个东西:
1:
value:sss
name:sdsff
text:sdfsdf
1:
value:dddddd
name:sdfsfdsf
text:sdfsfsf

------解决方案--------------------
string s = "1:value:sssname:sdsfftext:sdfsdf1:value:ddddddname:sdfsfdsftext:sdfsfsf";

for (int i = 0; i <= 10; i++)
{
s = s.Replace("1:", "#1:");
}
s = s.Replace("name:", "#name:");
s = s.Replace("value:", "#value:");
s = s.Replace("text:", "#text:");
string[] se = new string[] { "#" };
string[] al = s.Split(se, StringSplitOptions.RemoveEmptyEntries);
foreach (string str in al)
{
Console.WriteLine(str);
}
Console.ReadKey();
------解决方案--------------------
如果你希望后面的可以换行,那就加上换行符试试