Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace Message_Encrypter
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- string pattern = @"[*|@](?<tag>[A-Z][a-z]{2,})[*|@]: \[(?<number1>[A-Za-z])\]\|\[(?<number2>[A-Za-z])]\|\[(?<number3>[A-Za-z])\]\|$";
- var reg = new Regex(pattern);
- var match = reg.Match(input);
- if (!match.Success)
- {
- Console.WriteLine("Valid message not found!");
- continue;
- }
- else
- {
- string tag = match.Groups["tag"].Value;
- char num1 = char.Parse(match.Groups["number1"].Value);
- char num2 = char.Parse(match.Groups["number2"].Value);
- char num3 = char.Parse(match.Groups["number3"].Value);
- Console.WriteLine($"{tag}: {(int)num1} {(int)num2} {(int)num3} ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement