Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Text.RegularExpressions;
- public class Example
- {
- public static void Main()
- {
- string input = Console.ReadLine();
- var sb = new StringBuilder(input.Length);
- string pattern = @"(\w+)-\1";
- Regex rgx = new Regex(pattern);
- var matches = rgx.Matches(input);
- int position = 0;
- foreach (Match match in matches)
- {
- var index = match.Index;
- sb.Append(input.Substring(position, index));
- sb.Append(" ");
- position = index;
- position += match.Value.Length;
- }
- sb.Append(input.Substring(position, input.Length- 1));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement