Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Linq;
- namespace SOFTUNI
- {
- class Program
- {
- static void Main(string[] args)
- {
- string keys = Console.ReadLine();
- string text = Console.ReadLine();
- //string KeyStart = Regex.Match(keys, @"^[a-zA-Z]+[<|\\]").ToString();
- //KeyStart = KeyStart.Remove(KeyStart.Length - 1);
- //string KeyEnd = Regex.Match(keys, @"[<|\\][a-zA-Z]+$").ToString().Remove(0, 1);
- string[] keySplit = keys.Split('|', '<', '\\');
- string KeyStart = keySplit[0];
- string KeyEnd = keySplit[keySplit.Length - 1];
- //$@"{KeyStart}[a-zA-Z]*?{KeyEnd}"
- //$@"{KeyStart}\w*?{KeyEnd}"
- MatchCollection textMatches = Regex.Matches(text, $@"({KeyStart})+.*?({KeyEnd})+");
- string output = "";
- foreach (Match match in textMatches)
- {
- output += match.ToString().Replace(KeyStart, "").Replace(KeyEnd, "");
- }
- if (output != "")
- {
- Console.WriteLine(output);
- }
- else
- {
- Console.WriteLine("Empty result");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement