using System;
using System.Text.RegularExpressions;
class Program
{
static void Main() {
String s = "c# wwwww programming ooo w";
var matches = Regex.Matches(s, @"(.)\1+");
for (int i = 0; i < matches.Count; i++) {
Console.WriteLine(matches[i].Value + " : " + matches[i].Length + " times");
}
}
}
/*
run:
wwwww : 5 times
mm : 2 times
ooo : 3 times
*/