1string[] ParseCSVLine(string text)
2{
3 Regex rx = new Regex("((?([\\x27\\x22])(?:[\\x27\\x22])(?<Column>[^\\x27\\x22]*)(?:[\\x27\\x22])|(?<Column>[^,\r\n]*]*))(?:,?))+(?:$|[\r\n]{0,2})", RegexOptions.IgnorePatternWhitespace);
4
5 List<string> line = new List<string>();
6
7 foreach (Match m in rx.Matches(text))
8 {
9 if (m.Success)
10 {
11 foreach (Capture cp in m.Groups["Column"].Captures)
12 {
13 if (string.IsNullOrEmpty(cp.Value) == false)
14 line.Add(cp.Value);
15 }
16 }
17 }
18
19
20 return line.ToArray();
21}