日期:2014-05-18 浏览次数:20842 次
string str="aaaaaa,bbbbbb,ccccc,ddddd,eeeee"; string[] vtResult=str.Split(','); string[] _vtResult=Regex.Split(str,",");
------解决方案--------------------
1.字符串直接处理
string input = "aaaaaa,bbbbbb,ccccc,ddddd,eeeee";
string[] s = input.Split(new char[]{','});
for (int n = 0; n < s.Length; n++)
{
Console.WriteLine(s[n]);
}
2.使用正则表达式
string input = "aaaaaa,bbbbbb,ccccc,ddddd,eeeee";
string pattern = ",";
string[] s = Regex.Split(input, pattern, RegexOptions.IgnoreCase);
for (int n = 0; n < s.Length; n++)
{
Console.WriteLine(s[n]);
}