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 _03Problem_AnonumousVox
- {
- class Program
- {
- static void Main(string[] args)
- {
- string placeholderBlocks = Console.ReadLine();
- string[] values = Console.ReadLine().Split(new char[]{'{', '}'},StringSplitOptions.RemoveEmptyEntries).ToArray();
- string pattern = @"(?<startEnd>[A-Z-a-z]+)(?<placeholder>.+)(\k<startEnd>)";
- MatchCollection matchedPlaceholders = Regex.Matches(placeholderBlocks, pattern);
- int index = 0;
- foreach (Match matched in matchedPlaceholders)
- {
- string oldPlaceholder = matched.Groups["placeholder"].Value;
- string newPlaceholder = values[index];
- placeholderBlocks = placeholderBlocks.Replace(oldPlaceholder, newPlaceholder);
- index++;
- }
- Console.WriteLine(placeholderBlocks);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement