Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace Key_Replacer
- {
- class Program
- {
- static void Main(string[] args)
- {
- var pattern = @"([A-Za-z]+)([\|<\\])(.*)([\|<\\])([A-Za-z]+)";
- string input = Console.ReadLine();
- Match begin = Regex.Match(input, pattern);
- string start = begin.Groups[1].Value;
- string end = begin.Groups[5].Value;
- string input2 = Console.ReadLine();
- var pattern2 = $@"{start}(.*?){end}";
- MatchCollection result = Regex.Matches(input2, pattern2);
- if (result.Count > 0)
- {
- foreach (Match item in result)
- {
- Console.Write(item.Groups[1].Value);
- }
- }
- else
- {
- Console.WriteLine("Empty result");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement