Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- string type = @"^Type: (Normal|Warning|Danger)$";
- string source = @"^Source: ([A-Za-z0-9]+)$";
- string forecast = @"^Forecast: ([^!.,?]+)$";
- var input = Console.ReadLine();
- string[] output = new string[3];
- bool haveType = false;
- bool haveSource = false;
- bool typebool = true;
- while (input != "Davai Emo")
- {
- var isType = Regex.IsMatch(input, type);
- var isSource = Regex.IsMatch(input, source);
- var isForecast = Regex.IsMatch(input, forecast);
- if (isType && typebool == true)
- {
- RegexOptions options = RegexOptions.Multiline;
- foreach (Match m in Regex.Matches(input, type, options))
- {
- output[0] = m.Groups[1].ToString();
- }
- haveType = true;
- typebool = false;
- }
- if (isSource && haveType == true)
- {
- RegexOptions options2 = RegexOptions.Multiline;
- foreach (Match m in Regex.Matches(input, source, options2))
- {
- output[1] = m.Groups[1].ToString();
- }
- haveSource = true;
- }
- if (isForecast && haveSource == true)
- {
- RegexOptions options3 = RegexOptions.Multiline;
- foreach (Match m in Regex.Matches(input, forecast, options3))
- {
- output[2] = m.Groups[1].ToString();
- }
- Console.WriteLine("({0}) {1} ~ {2}", output[0].ToString(), output[2], output[1].ToString());
- haveType = false;
- haveSource = false;
- typebool = true;
- }
- input = Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement