Advertisement
Guest User

hello

a guest
Mar 29th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _02._Message_Encrypter__03_August_2019_Group_2
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n = int.Parse(Console.ReadLine());
  11.  
  12. //string pattern = @"[\*|\@](?<tag>[A-Z][a-z]{2,})[\*|\@]: \[(?<group1>[A-za-z])\]\|\[(?<group2>[A-Za-z])\]\|\[(?<group3>[A-Za-z])\]\|?";
  13. string pattern = @"[@|*](?<tag>[A-Za-z]{3,})[@|*]:\s\[(?<group1>[A-Z]|[a-z])\]\|\[(?<group2>[A-Z]|[a-z])\]\|\[(?<group3>[A-Z]|[a-z])\]\|$";
  14. //int messageGroup2 = 0;
  15. //int messageGroup3 = 0;
  16. //int messageGroup4 = 0;
  17.  
  18. for (int i = 0; i < n; i++)
  19. {
  20. string encryptMessage = Console.ReadLine();
  21.  
  22. Match match = Regex.Match(encryptMessage, pattern);
  23.  
  24. if (match.Success)
  25. {
  26. string tag = match.Groups["tag"].Value;
  27. //string group2 = match.Groups["group1"].Value;
  28. //string group3 = match.Groups["group2"].Value;
  29. //string group4 = match.Groups["group3"].Value;
  30.  
  31. // string title = match.Groups["title"].Value;
  32. char group2 = char.Parse(match.Groups["group1"].Value);
  33. char group3 = char.Parse(match.Groups["group2"].Value);
  34. char group4 = char.Parse(match.Groups["group3"].Value);
  35.  
  36. //for (int j = 0; j < group2.Length; j++)
  37. //{
  38. // messageGroup2 = group2[i];
  39. //}
  40. //for (int k = 0; k < group2.Length; k++)
  41. //{
  42. // messageGroup3 = group3[i];
  43. //}
  44. //for (int k = 0; k < group4.Length; k++)
  45. //{
  46. // messageGroup4 = group4[i];
  47. //}
  48. Console.WriteLine($"{tag}: {(int)group2} {(int)group3} {(int)group4} ");
  49. }
  50. else
  51. {
  52. Console.WriteLine("Valid message not found!");
  53. }
  54. }
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement