using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; namespace MarketData.CSVHelper { public class StringParser { private StringParser() { } public static string[] ParseDelimitedString(string arguments, char delim = ',') { var regex = new Regex("(?<=^|,)(\"(?:[^\"]|\"\")*\"|[^,]*)"); List values = new List(); foreach (Match m in regex.Matches(arguments)) { String value = m.Value; if (null != value && value.StartsWith("\"") && value.EndsWith("\"")) { value = value.Substring(1, value.Length - 2); } values.Add(value); } return values.ToArray(); } } }