Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Linq;
- using System.Globalization;
- using System.Numerics;
- class Program
- {
- static void Main(string[] args)
- {
- string key = Console.ReadLine();
- string patternKey = @"(?<start>[a-zA-Z]+)(\||\\|<)((\w*\W*)*(\||\\|<))*(?<end>[a-zA-Z]+)";
- string text = Console.ReadLine();
- Match matchKey = Regex.Match(key, patternKey);
- string start ="{" + matchKey.Groups["start"].Value + "}";
- string end = "{" + matchKey.Groups["end"].Value + "}";
- string patternText = $@"{start}(?<between>.*?){end}";
- MatchCollection matches = Regex.Matches(text, patternText);
- string final = null;
- foreach (Match item in matches)
- {
- final+=item.Groups["between"].Value;
- }
- Console.WriteLine(final);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment