// 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; public class Test { public static void Parse(string s) { Console.WriteLine(s); MatchCollection res = Regex.Matches(s,"([a-zA-Z_][a-zA-Z_0-9]*)(?: )(\")([^\"]*)(\")(;)"); for(int i = 0; i < res.Count; i++) { Console.WriteLine("func=" + res[i].Groups[1]); Console.WriteLine("stringsep=" + res[i].Groups[2]); Console.WriteLine("string=" + res[i].Groups[3]); Console.WriteLine("stringsep=" + res[i].Groups[4]); Console.WriteLine("statementsep=" + res[i].Groups[5]); } } public static void Main(string[] args) { Parse("a \"aa\";"); Parse("b \"bb bb\";"); } }