Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _02._Program
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- var regex = @"([@*])(?<command>[A-Z]{1,1}[a-z]{2,})(\1): \[(?<firstGroup>[A-Za-z])\]\|\[(?<secondGroup>[A-Za-z])\]\|\[(?<thirdGroup>[A-Za-z])\]\|$";
- for (int i = 0; i < n; i++)
- {
- string message = Console.ReadLine();
- Match m = Regex.Match(message, regex);
- if (m.Success)
- {
- string command = m.Groups["command"].Value;
- var firstGroup = Convert.ToChar(m.Groups["firstGroup"].Value);
- var secondGroup = Convert.ToChar(m.Groups["secondGroup"].Value);
- var thirdGroup = Convert.ToChar(m.Groups["thirdGroup"].Value);
- Console.WriteLine($"{command}: {(int)firstGroup} {(int)secondGroup} {(int)thirdGroup}");
- }
- else
- {
- Console.WriteLine($"Valid message not found!");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment