Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace text
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- var regex = new Regex(@"\b(?<day>[0-9]{2})([-.\/])(?<month>[A-Z][a-z]{2})\1(?<year>[0-9]{4})\b");//group 1 is the first group without name; group 2 is the second group without name; all groups with names are after tha last group without name;
- var text = Console.ReadLine();
- var matches = regex.Matches(text);
- foreach (Match match in matches)
- {
- var day = match.Groups["day"].Value;//group 2
- var month = match.Groups["month"].Value;//group 3
- var year = match.Groups["year"].Value;//group 4
- Console.WriteLine($"Day: {day}, Month: {month}, Year: {year}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement