using System.Text.RegularExpressions;
using System.Diagnostics;
public static void Main()
var str = string.Concat(System.Linq.Enumerable.Repeat("1234567890", 2000));
Stopwatch stopWatch = new Stopwatch();
for(int i = 0; i < repeat; i++)
str1 = str.Replace("2"," ").Replace("7"," ");
var elapsed = stopWatch.Elapsed;
Console.WriteLine("String replace: " + elapsed);
for(int i = 0; i < repeat; i++)
str1 = str.Replace('2',' ').Replace('7',' ');
elapsed = stopWatch.Elapsed;
Console.WriteLine("Char replace: " + elapsed);
for(int i = 0; i < repeat; i++)
str1 = Regex.Replace(str,"2|7"," ");
elapsed = stopWatch.Elapsed;
Console.WriteLine("Regex replace: " + elapsed);