Console.WriteLine (Regex.Match ("color", @"colou?r").Success); // True Console.WriteLine (Regex.Match ("colour", @"colou?r").Success); // True Console.WriteLine (Regex.Match ("colouur", @"colou?r").Success); // False
Match m = Regex.Match ("any colour you like", @"colou?r"); Console.WriteLine (m.Success); // True Console.WriteLine (m.Index); // 4 Console.WriteLine (m.Length); // 6 Console.WriteLine (m.Value); // colour Console.WriteLine (m.ToString()); // colour
Match m1 = Regex.Match ("One color? There are two colours in my head!",@"colou?rs?"); Match m2 = m1.NextMatch(); Console.WriteLine (m1); // color Console.WriteLine (m2); // colours
foreach (Match m in Regex.Matches("One color? There are two colours in my head!", @"colou?rs?")) Console.WriteLine (m);