diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 6a2784cc98..0da99b42f0 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -1191,17 +1191,15 @@ namespace Umbraco.Core /// Updated string public static string Replace(this string source, string oldString, string newString, StringComparison stringComparison) { - var index = source.IndexOf(oldString, stringComparison); + int index; - // Determine if we found a match - var matchFound = index >= 0; - - if (matchFound) + // Determine if there are any matches left in source. + while((index = source.IndexOf(oldString, stringComparison)) >= 0) { - // Remove the old text + // Remove the old text. source = source.Remove(index, oldString.Length); - // Add the replacemenet text + // Add the replacemenet text. source = source.Insert(index, newString); }