Mega Code Archive

 
Categories / C# / Development Class
 

Use regular to verify a date

using System; using System.Text.RegularExpressions; class RegexMatches {    public static void Main()    {       Regex expression = new Regex( @"J.*\d[0-35-9]-\d\d-\d\d" );       string string1 = "Jane's Birthday is 05-12-75\n" +          "Jave's Birthday is 11-04-78\n" +          "John's Birthday is 04-28-73\n" +          "Joe's Birthday is 12-17-77";       foreach ( Match myMatch in expression.Matches( string1 ) )          Console.WriteLine( myMatch );    } }