ellapt

T14.23.ReduceConsecutiveLetters

Feb 3rd, 2013
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. class ReduceConsecutiveLetters
  5. {
  6. static void Main()
  7. {
  8. Console.WriteLine("Replace all series of consecutive identical letters with a single one. Example: \n");
  9.  
  10. string text = "Theeee microooooooprocessor operrrrrrrrrrrrrates on numbers annnnnnndddddddddddd symbbbbbbbbols";
  11. Console.WriteLine("Original text:\n{0}\n", text);
  12. Console.WriteLine(Regex.Replace(text, @"(\w)\1+", "$1"));
  13. Console.WriteLine();
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment