Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace _2.AnonimousVox
- {
- class Program
- {
- static void Main(string[] args)
- {
- string textToEncode = Console.ReadLine();
- string[] values = Console.ReadLine()
- .Split(new char[] { '{', '}'},StringSplitOptions.RemoveEmptyEntries )
- .ToArray();
- string pattern = @"([A-Za-z]+)(.+)\1";
- Regex regex = new Regex(pattern);
- MatchCollection matches = regex.Matches(textToEncode);
- int valueIndex = 0;
- foreach (Match match in matches)
- {
- if(valueIndex >= values.Length)
- {
- break;
- }
- string result = Regex.Replace(textToEncode, match.Groups[2].Value, values[valueIndex++]);
- Console.WriteLine(result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment