日期:2014-05-17  浏览次数:21288 次

字符串变数组
string str = "01020304050607";

List<string> grp = new List<string>();

for (int i = 0; i <= 12; i += 2)
{
  grp.add(str.substring(n,2));
}


把字符串"01020304050607",变成了{"01","02","03","04","05","06","07"}


还有更简单的方法,或者说 效率更高的办法吗? 谢谢

------解决方案--------------------
string str = "01020304050607";
List<string> grp = Regex.Matches(str, "\\d{2}").Cast<Match>().Select(x => x.Value).ToList();

手写的,不一定对。
------解决方案--------------------
试试
string[] strs = "01020304050607".Split("(?<=\\G.{2})(?!$)");