Advertisement
Guest User

Message Decrypter

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