Created
May 13, 2015 11:49
-
-
Save aanguelov/0d3d5b79d4895ced4837 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
namespace SeriesOfLetters | |
{ | |
class SeriesOfLetters | |
{ | |
static void Main(string[] args) | |
{ | |
string text = Console.ReadLine(); | |
string pattern = @"([a-z])\1+"; | |
Regex regex = new Regex(pattern); | |
MatchCollection matches = Regex.Matches(text,pattern); | |
for (int i = 0; i < matches.Count; i++) | |
{ | |
string tempPattern = matches[i].ToString(); | |
string replace = tempPattern.First().ToString(); | |
Regex tempRegex = new Regex(tempPattern); | |
text = tempRegex.Replace(text, replace); | |
} | |
Console.WriteLine(text); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment