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+", " ")); } }
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+", " ")); } }