Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Exercise
- {
- class Program
- {
- static void Main(string[] args)
- {
- var placeholder = Console.ReadLine();
- var regPlace = @"([A-Za-z]+)(.+)\1";
- var value = Console.ReadLine();
- var regValue = @"({)(.*?)(})";
- //
- MatchCollection placeholderCollection = Regex.Matches(placeholder,regPlace);
- MatchCollection valueCollection = Regex.Matches(value, regValue);
- //
- for (int i = 0; i < Math.Min(placeholderCollection.Count, valueCollection.Count); i++)
- {
- string toChange = placeholderCollection[i].Groups[2].Value;
- string toPut = valueCollection[i].Groups[2].Value;
- int index = placeholder.IndexOf(toChange);
- placeholder = placeholder.Remove(index, toChange.Count());
- placeholder = placeholder.Insert(index, toPut);
- }
- Console.WriteLine(placeholder);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement