// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text.RegularExpressions; namespace E { public class MainClass { public static void Main(string[] args) { string s = @"[""En streng"", 123, -32, 321, ""A""], [""En streng2"", 456, 432, 4325, ""B""], [""En streng3"", 789, 0, 7635, ""C""]"; Console.WriteLine(s); //Regex re = new Regex(@"(?:\["")([A-Za-z0-9 ]*)(?:"",[ ]*)([-]*[0-9]+)(?:,[ ]*)([-]*[0-9]+)(?:,[ ]*)([-]*[0-9]+)(?:,[ ]*"")([A-Za-z0-9 ]*)(?:""\])", RegexOptions.Singleline); Regex re = new Regex(@"(?:\["")([^""]*)(?:"",[ ]*)([-]*[0-9]+)(?:,[ ]*)([-]*[0-9]+)(?:,[ ]*)([-]*[0-9]+)(?:,[ ]*"")([^""]*)(?:""\])", RegexOptions.Singleline); MatchCollection mc = re.Matches(s); foreach(Match m in mc) { Console.WriteLine(m.Groups[0].Value); Console.WriteLine(m.Groups[1].Value + " " + m.Groups[2].Value + " " + m.Groups[3].Value + " " + m.Groups[4].Value + " " + m.Groups[5].Value); } } } }