Mega Code Archive

 
Categories / C# / Development Class
 

Gr(ae)y

using System; using System.Text.RegularExpressions; public class MainClass {     public static void Main() {         Regex n = new Regex("Gr(a|e)y");         MatchCollection mp = n.Matches("Green, Grey, Granite, Gray");         for (int i = 0; i < mp.Count; i++) {             Console.WriteLine("Found '{0}' at position {1}",mp[i].Value, mp[i].Index);         }     } }