日期:2014-05-20 浏览次数:20772 次
string str = "A张三A李四A王五A马六"; str = string.Join("\n", str.Split('A').Select((x, i) => i.ToString() + "," + x).Skip(1).ToArray());
------解决方案--------------------
string str="A张三A李四A王五A马六";
int i=0;
str=Regex.Replace(str,"A",m=>{i++;return "\n"+i+",";});
------解决方案--------------------
string str = "A张三A李四A王五A马六"; int i = 0; string r = Regex.Replace(str, @"A([^A]+)", delegate(Match match) { i++; return i + "," + match.Groups[1].Value + "\n"; }); Console.Write(r);