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;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace crap
- {
- class Program
- {
- static void Main(string[] args)
- {
- string regex = @"\b(?<day>\d{2})([-.\/])(?<month>[A-Z][a-z]{2})\2(?<year>\d{4})\b";
- string datesStrings = Console.ReadLine();
- MatchCollection dates = Regex.Matches(datesStrings, regex);
- foreach (Match date in dates)
- {
- var day = date.Groups["day"].Value;
- var month = date.Groups["month"].Value;
- var year = date.Groups["year"].Value;
- Console.WriteLine($"Day: {day}, Month: {month}, Year: {year}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment