yushff

code the world。

导航

C#字符串分割成数组,中间多空格

Posted on 2013-05-25 20:44  yushff  阅读(1068)  评论(0编辑  收藏  举报

方法如下,使用正则表达式:

 string abc = "3  45  55  55  676 11";

 

 string str = System.Text.RegularExpressions.Regex.Replace(abc, @"\s+", ",");

 string[] aa =str.Split(',');

 

也可以直接分割:

 string[] aa = System.Text.RegularExpressions.Regex.Split(abc, @"\s+");

from: http://hi.baidu.com/zhenzhounew/item/87497ee3be1277c3baf37df8