using System.Diagnostics;
using System.Text.RegularExpressions;
public static void Main()
var message = "Hello World Hello world hello world \n hello hello";
public static void StringReplace(string input)
var stopWatch = new Stopwatch();
var output = input.Replace("\n", "").Replace(" ", "");
Console.WriteLine($"String Replace: {output} in {stopWatch.Elapsed}({stopWatch.Elapsed.Humanize()})");
public static void RegexReplace(string input)
var stopWatch = new Stopwatch();
var output = Regex.Replace(input, @"\s+", "");
Console.WriteLine($" Regex: {output} in {stopWatch.Elapsed}({stopWatch.Elapsed.Humanize()})");