Introduction
The example tries to match birthdays to a regular expression. For demonstration purposes, the expression matches only birthdays that do not occur in April and that belong to people whose names begin with
"k".
-
- Regex expression = new Regex(@"K.*\d[0-35-9]-\d\d-\d\d");
- string string1 = "Kanhu's Birthday is 05-12-75\n" + "Panchanan's Birthday is 11-04-68\n" + "Suraj's Birthday is 04-28-73\n" +"Kailash's Birthday is 12-17-77";
-
-
- foreach (Match myMatch in expression.Matches(string1))
- Console.WriteLine(myMatch);
- Console.ReadLine();
Output