Advertisement
Lamms

ShmoogleCounter

Oct 16th, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace _03ShmoogleCounter
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string text = Console.ReadLine();
  15. // string myString = text.Replace(System.Environment.NewLine, " ");
  16. string pattern = @"\bint\b \b([a-z][a-zA-Z]{0,24})\b";
  17. Regex regex = new Regex(pattern);
  18. Match match = regex.Match(text);
  19. List<string> result = new List<string>();
  20. MatchCollection matches = Regex.Matches(text, pattern);
  21. string none = "None";
  22. string pattern2 = @"\bdouble\b \b([a-z][a-zA-Z]{0,24})\b";
  23. Regex regex2 = new Regex(pattern2);
  24.  
  25. List<string> result2 = new List<string>();
  26. //int countInt = 0;
  27. Match match2 = regex2.Match(text);
  28.  
  29. MatchCollection matches2 = Regex.Matches(text, pattern2);
  30. // MatchCollection matches2 = Regex.Matches(text, pattern2);
  31. while (text != "//END_OF_CODE")
  32. {
  33. if (regex.IsMatch(text))
  34. {
  35. // match = regex.Match(text);
  36.  
  37. matches = Regex.Matches(text, pattern);
  38.  
  39.  
  40. foreach (Match mat in matches)
  41. {
  42. //Console.WriteLine(match.Value);
  43. result.Add(mat.Groups[1].Value);
  44. // countInt++;
  45.  
  46. }
  47.  
  48.  
  49. }
  50. else if (regex2.IsMatch(text))
  51. {
  52. match2 = regex2.Match(text);
  53. matches2 = Regex.Matches(text, pattern2);
  54. foreach (Match item in matches2)
  55. {
  56.  
  57.  
  58. result2.Add(item.Groups[1].Value);
  59.  
  60. // match2 = match2.NextMatch();
  61. }
  62. }
  63. // match = match.NextMatch();
  64. text = Console.ReadLine();
  65. }
  66.  
  67.  
  68. // Console.WriteLine(5);
  69. //result.Add(match.Groups[1].Value);
  70. //countInt = Regex.Matches(text, pattern).Count;
  71. // match = match.NextMatch();
  72. //text =Console.ReadLine();
  73. result.Sort();
  74. result2.Sort();
  75. Console.Write("Doubles: ");
  76. if (result2.Count != 0)
  77. {
  78.  
  79. Console.WriteLine(string.Join(", ", result2));
  80. }
  81. else
  82. {
  83. Console.WriteLine("None");
  84. }
  85. Console.Write("Ints: ");
  86. if (result.Count != 0)
  87. {
  88. Console.WriteLine(string.Join(", ", result));
  89.  
  90. }
  91. else
  92. {
  93. Console.WriteLine("None");
  94. }
  95.  
  96.  
  97.  
  98.  
  99.  
  100. // Console.WriteLine(countInt);
  101.  
  102. // if text.Contains("int");
  103.  
  104. // Console.WriteLine("Doubles: None");
  105. // Console.WriteLine("Ints: None");
  106. }
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement