Advertisement
silvana1303

message encrypter

Aug 8th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace _02._Boss_Rush
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Regex regex = new Regex(@"(\*|\@)(?<tag>[A-Z][a-z]{2,})(\1): \[(?<first>[A-Z]|[a-z])\]\|\[(?<second>[A-Z]|[a-z])\]\|\[(?<third>[A-Z]|[a-z])\]\|$");
  13.  
  14.             int count = int.Parse(Console.ReadLine());
  15.  
  16.             for (int i = 0; i < count; i++)
  17.             {
  18.                 string input = Console.ReadLine();
  19.  
  20.                 Match match = regex.Match(input);
  21.  
  22.                 if (match.Success)
  23.                 {
  24.                     string tag = match.Groups["tag"].Value;
  25.                     char first = char.Parse(match.Groups["first"].Value);
  26.                     char second = char.Parse(match.Groups["second"].Value);
  27.                     char third = char.Parse(match.Groups["third"].Value);
  28.  
  29.                     Console.WriteLine($"{tag}: {(int)first} {(int)second} {(int)third}");
  30.                 }
  31.                 else
  32.                 {
  33.                     Console.WriteLine("Valid message not found!");
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement