Advertisement
Guest User

Untitled

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