Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _02._Message_Encrypter__03_August_2019_Group_2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- //string pattern = @"[\*|\@](?<tag>[A-Z][a-z]{2,})[\*|\@]: \[(?<group1>[A-za-z])\]\|\[(?<group2>[A-Za-z])\]\|\[(?<group3>[A-Za-z])\]\|?";
- string pattern = @"[@|*](?<tag>[A-Za-z]{3,})[@|*]:\s\[(?<group1>[A-Z]|[a-z])\]\|\[(?<group2>[A-Z]|[a-z])\]\|\[(?<group3>[A-Z]|[a-z])\]\|$";
- //int messageGroup2 = 0;
- //int messageGroup3 = 0;
- //int messageGroup4 = 0;
- for (int i = 0; i < n; i++)
- {
- string encryptMessage = Console.ReadLine();
- Match match = Regex.Match(encryptMessage, pattern);
- if (match.Success)
- {
- string tag = match.Groups["tag"].Value;
- //string group2 = match.Groups["group1"].Value;
- //string group3 = match.Groups["group2"].Value;
- //string group4 = match.Groups["group3"].Value;
- // string title = match.Groups["title"].Value;
- char group2 = char.Parse(match.Groups["group1"].Value);
- char group3 = char.Parse(match.Groups["group2"].Value);
- char group4 = char.Parse(match.Groups["group3"].Value);
- //for (int j = 0; j < group2.Length; j++)
- //{
- // messageGroup2 = group2[i];
- //}
- //for (int k = 0; k < group2.Length; k++)
- //{
- // messageGroup3 = group3[i];
- //}
- //for (int k = 0; k < group4.Length; k++)
- //{
- // messageGroup4 = group4[i];
- //}
- Console.WriteLine($"{tag}: {(int)group2} {(int)group3} {(int)group4} ");
- }
- else
- {
- Console.WriteLine("Valid message not found!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement