Advertisement
ctelio

5-ta

Feb 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace Key_Replacer
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var pattern = @"([A-Za-z]+)([\|<\\])(.*)([\|<\\])([A-Za-z]+)";
  11.             string input = Console.ReadLine();
  12.             Match begin = Regex.Match(input, pattern);
  13.             string start = begin.Groups[1].Value;
  14.             string end = begin.Groups[5].Value;
  15.             string input2 = Console.ReadLine();
  16.             var pattern2 = $@"{start}(.*?){end}";
  17.             MatchCollection result = Regex.Matches(input2, pattern2);
  18.             if (result.Count > 0)
  19.             {
  20.                 foreach (Match item in result)
  21.                 {
  22.                     Console.Write(item.Groups[1].Value);
  23.                 }
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine("Empty result");
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement