Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace _08.Match_Dates
- {
- class Program
- {
- static void Main(string[] args)
- {
- var regex = @"\b(?<day>\d{2})([-.\/])(?<month>[A-Z][a-z]{2})\1(?<year>\d{4})\b";
- var input = Console.ReadLine();
- var result = Regex.Matches(input,regex);
- foreach (Match date in result)
- {
- var day = date.Groups["day"].Value;
- var month = date.Groups["month"].Value;
- var year = date.Groups["year"].Value;
- Console.WriteLine("Day: {0}, Month: {1}, Year: {2}",day,month,year);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment