а string origin?
public static class StringExtentions
{
public static string CustomReplace(this string origin, string from, string to)
{
var sb = new StringBuilder();
int position = 0;
do
{
var quoteStart = origin.IndexOf('"', position);
if (quoteStart == -1)
quoteStart = origin.Length;
var headLength = quoteStart - position;
if (headLength > 0)
{
sb.Append(origin.Substring(position, headLength).Replace(from, to));
}
position = quoteStart;
if(position == origin.Length) break;
var quoteEnd = origin.IndexOf('"', position + 1);
if (quoteEnd == -1)
quoteEnd = origin.Length;
var tailLength = quoteEnd + 1 - position;
if (tailLength > 0)
{
sb.Append(origin.Substring(position, tailLength));
}
position = quoteEnd + 1;
} while (position < origin.Length);
return sb.ToString();
}
}
не такая уж большая разница, на самом деле
цитата отсюда