110,566
社区成员
发帖
与我相关
我的任务
分享
string[] lines = Regex.Split(yourStr, @"(?<=,[^,""]*\r?)\n(?!$)");
for (int i = 1; i <= lines.Length; i++)
{
MatchCollection mc = Regex.Matches(lines[i - 1], @"""(?<o>[^,]*?)""(?=,|$)|""(?<o>[^""]*)""|(?<o>[^,""]+)");
for (int j = 1; j <= mc.Count; j++)
{
richTextBox2.Text += "[" + i + "," + j + "] = " + mc[j - 1].Groups["o"].Value + "\n";
}
}
[1,1] = a
[1,2] = b
[1,3] = a,2
[1,4] = 123""456
[1,5] = AAA
BBB
[1,6] = 1000
[2,1] = 100
[2,2] = 200
[2,3] = 3,000
[2,4] = 400
[2,5] = 500
[2,6] = 600
(?:\"(?>[^\"]*(?:\"{2})?|\"(?<D>)|\"(?<-D>))*(?(D)(?!))\")|[^,\\n]*