kilya

Checking_Date_format

Feb 10th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace Regular_Expression
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] calender = {
  11.                 "1/02/2019",
  12.                 "01/12/1990",
  13.                 "11/12/1990",
  14.                 "00/12/1990",
  15.                 "01/12/19900",
  16.                 "99/12/1990"
  17.  
  18.             };
  19.  
  20.             for (int i = 0; i < calender.Length; i++)
  21.             {
  22.                 string pattern = @"^(0?[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/\d{4}$";
  23.                 bool ismatch = Regex.IsMatch(calender[i], pattern);
  24.                 Console.WriteLine(ismatch);
  25.             }
  26.             Console.ReadLine();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment