svetliovd

Untitled

Aug 5th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace crap
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string regex = @"\b(?<day>\d{2})([-.\/])(?<month>[A-Z][a-z]{2})\2(?<year>\d{4})\b";
  15.             string datesStrings = Console.ReadLine();
  16.             MatchCollection dates = Regex.Matches(datesStrings, regex);
  17.             foreach (Match date in dates)
  18.             {
  19.                 var day = date.Groups["day"].Value;
  20.                 var month = date.Groups["month"].Value;
  21.                 var year = date.Groups["year"].Value;
  22.  
  23.                 Console.WriteLine($"Day: {day}, Month: {month}, Year: {year}");
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment