Advertisement
Stan0033

Untitled

Aug 1st, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. namespace apps
  8. {
  9. class Program
  10. {
  11. static string Get() { return Console.ReadLine(); }
  12.  
  13.  
  14.  
  15.  
  16. static void Main()
  17. {
  18. // ticket
  19. string raw = Get();
  20. List<string> rawList = raw.Split(", ").ToList();
  21. //foreach (var v in rawList) { v.Trim(); }
  22. string pattern = @"[A-Za-z]*(?<money>[$|@|#|^]{6,10})[A-Za-z]*[$|@|#|^]{6,10}[A-Za-z]*";
  23. //-------------------------------------------------------------------------------------------
  24. //-------------------------------------------------------------------------------------------
  25.  
  26. //-------------------------------------------------------------------------------------------
  27. //-------------------------------------------------------------------------------------------
  28. MatchCollection matches = Regex.Matches(raw, pattern);
  29.  
  30. for (int i = 0; i < rawList.Count; i++)
  31. {
  32. Match m = Regex.Match(rawList[i], pattern);
  33.  
  34. if (Regex.IsMatch(rawList[i], pattern))
  35. {
  36. int len = m.Groups["money"].Length;
  37. string currencies = m.Groups["money"].ToString();
  38. if (m.Length != 20) { Console.WriteLine("invalid ticket"); continue; }
  39. char currency = currencies[0];
  40. if (len == 10)
  41. {
  42. Console.WriteLine($"ticket \"{m}\" - {len}{currency} Jackpot!");
  43. }
  44. else
  45. {
  46. Console.WriteLine($"ticket \"{m}\" - {len}{currency}");
  47. }
  48. }
  49. else
  50. {
  51. if (rawList[i].Length == 20)
  52. {
  53.  
  54. Console.WriteLine($"ticket \"{rawList[i]}\" - no match");
  55. }
  56. else
  57. {
  58. { Console.WriteLine("invalid ticket"); }
  59. }
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. }
  68.  
  69.  
  70. }// END MAIN
  71.  
  72. }
  73. }
  74.  
  75.  
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement