// 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 Program { public static void Test(string re1, string s1) { Regex re = new Regex(re1); Match m = re.Match(s1); Console.WriteLine(re1 + " " + s1 + " : " + m.Success + (m.Success ? (" " + m.Value) : "")); } public static void Main(string[] args) { string[] re = { "x.+y", "x.+?y", "x.?y", "x.*y" }; string[] s = { "xy", "x1y", "x12y", "x1yx2y" }; foreach(string re1 in re) { foreach(string s1 in s) { Test(re1,s1); } } } } }