Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7. using System.Linq;
  8.  
  9.  
  10. class Program
  11. {
  12. static void Main()
  13. {
  14. string type = @"^Type: (Normal|Warning|Danger)$";
  15. string source = @"^Source: ([A-Za-z0-9]+)$";
  16. string forecast = @"^Forecast: ([^!.,?]+)$";
  17.  
  18. var input = Console.ReadLine();
  19. string[] output = new string[3];
  20. bool haveType = false;
  21. bool haveSource = false;
  22. bool typebool = true;
  23.  
  24.  
  25. while (input != "Davai Emo")
  26. {
  27. var isType = Regex.IsMatch(input, type);
  28. var isSource = Regex.IsMatch(input, source);
  29. var isForecast = Regex.IsMatch(input, forecast);
  30. if (isType && typebool == true)
  31. {
  32. RegexOptions options = RegexOptions.Multiline;
  33.  
  34. foreach (Match m in Regex.Matches(input, type, options))
  35. {
  36. output[0] = m.Groups[1].ToString();
  37.  
  38. }
  39. haveType = true;
  40. typebool = false;
  41. }
  42. if (isSource && haveType == true)
  43. {
  44. RegexOptions options2 = RegexOptions.Multiline;
  45.  
  46. foreach (Match m in Regex.Matches(input, source, options2))
  47. {
  48. output[1] = m.Groups[1].ToString();
  49.  
  50. }
  51. haveSource = true;
  52. }
  53. if (isForecast && haveSource == true)
  54. {
  55. RegexOptions options3 = RegexOptions.Multiline;
  56.  
  57. foreach (Match m in Regex.Matches(input, forecast, options3))
  58. {
  59. output[2] = m.Groups[1].ToString();
  60. }
  61. Console.WriteLine("({0}) {1} ~ {2}", output[0].ToString(), output[2], output[1].ToString());
  62. haveType = false;
  63. haveSource = false;
  64. typebool = true;
  65. }
  66. input = Console.ReadLine();
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement