Replace multiply whitespaces with single space inside text using C#.

using System;
using System.Text.RegularExpressions;

static class ReplaceWhiteSpaces
{
    public static void Main()
    {
        string text = "This is some   text    with        whitespaces in    it   . :     )";
        Console.WriteLine(Regex.Replace(text, @"(\s)\1+", " "));
    }
}