Use regular to verify a date

image_pdfimage_print


   


using System;
using System.Text.RegularExpressions;

class RegexMatches
{
   public static void Main()
   {
      Regex expression = new Regex( @"J.*d[0-35-9]-dd-dd" );

      string string1 = "Jane's Birthday is 05-12-75
" +
         "Jave's Birthday is 11-04-78
" +
         "John's Birthday is 04-28-73
" +
         "Joe's Birthday is 12-17-77";

      foreach ( Match myMatch in expression.Matches( string1 ) )
         Console.WriteLine( myMatch );
   }
}