Advertisement
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;
- namespace Match_Dates
- {
- class Program
- {
- static void Main(string[] args)
- {
- string pattern = @"([0-9]{2}[\/][A-Z]{1}[a-z]{2}[\/][0-9]{4})|([0-9]{2}[\-][A-Z]{1}[a-z]{2}[\-][0-9]{4})|([0-9]{2}[\.][A-Z]{1}[a-z]{2}[\.][0-9]{4})";
- string input = Console.ReadLine();
- MatchCollection days = Regex.Matches(input, pattern);
- Dictionary<string, Dictionary<string, string>> store =
- new Dictionary<string, Dictionary<string, string>>();
- foreach (Match data in days)
- {
- string[] tokens = data.Value.Split('/', '.', '-');
- string day = tokens[0];
- string month = tokens[1];
- string year = tokens[2];
- if (!store.ContainsKey(day))
- {
- store.Add(day, new Dictionary<string, string>());
- }
- store[day][month] = year;
- }
- foreach (var data in store)
- {
- Console.Write($"Day: {data.Key}, ");
- Dictionary<string, string> second = data.Value;
- foreach (var entry in second)
- {
- Console.Write($"Month: {entry.Key}, Year: {entry.Value}");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement