using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.IO; using System.Xml; using System.Text.RegularExpressions; public static class GlobalExtensionMethods { public static string Replace( this string source, string oldValue, string newValue, StringComparison comparisonType) { StringBuilder sb = new StringBuilder(); int previousIndex = 0; int index = source.IndexOf(oldValue, comparisonType); while (index != -1) { sb.Append(source.Substring(previousIndex, index - previousIndex)); sb.Append(newValue); index += oldValue.Length; previousIndex = index; index = source.IndexOf(oldValue, index, comparisonType); } sb.Append(source.Substring(previousIndex)); return sb.ToString(); } }