// 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) { MatchCollection res = Regex.Matches(s,"(?:stat\\(\")([^\"]*)(?:\",\")([^\"]*)(?:\"\\);)"); for(int i = 0; i < res.Count; i++) { Console.WriteLine("stat " + res[i].Groups[1] + " " + res[i].Groups[2]); } } public static void Main(string[] args) { string s = "// yyy xxx\r\n" + "stat(\"yyy\",\"xxx\");\r\n" + "// aaa bbb\r\n" + "stat(\"aaa\",\"bbb\");\r\n"; Console.WriteLine(s); Parse(s); } }