Advertisement
social1986

Untitled

Oct 27th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Example
  6. {
  7. public static void Main()
  8. {
  9. string input = Console.ReadLine();
  10. var sb = new StringBuilder(input.Length);
  11.  
  12. string pattern = @"(\w+)-\1";
  13. Regex rgx = new Regex(pattern);
  14. var matches = rgx.Matches(input);
  15. int position = 0;
  16.  
  17. foreach (Match match in matches)
  18. {
  19. var index = match.Index;
  20. sb.Append(input.Substring(position, index));
  21. sb.Append(" ");
  22. position = index;
  23. position += match.Value.Length;
  24. }
  25. sb.Append(input.Substring(position, input.Length- 1));
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement