Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace Regexer
- {
- class Program
- {
- static void Main(string[] args)
- {
- string lineOne = Console.ReadLine();
- string lineTwo = Console.ReadLine();
- string keyWordsPattern = @"(?<StartKey>^.*?)(?=[|<\\])(.*(?=[|<\\]).{1})(?<EndKey>.*\b)";
- Match match = Regex.Match(lineOne, keyWordsPattern);
- string startWord = match.Groups["StartKey"].Value;
- string endWord = match.Groups["EndKey"].Value;
- string pattern = $@"{startWord}(.*?)(?={endWord})";
- MatchCollection matches = Regex.Matches(lineTwo, pattern);
- Match heya = Regex.Match(lineTwo, pattern);
- if (heya.Groups[1].Value == String.Empty)
- {
- Console.WriteLine("Empty result");
- return;
- }
- foreach (Match word in matches)
- {
- Console.Write(word.Groups[1]);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement