public string Replace(Func<Match, string> matchEvaluator, int count = int.MaxValue)
{
var inputReplacement = new StringBuilder(_input);
var replacementLengthDifference = 0;
// We need to account for the possibility that a replacement might have a different length than its match.
var match = GetMatch();
for (var i = 0; i < count && match != null; i++, match = match.NextMatch())
{
var replacement = matchEvaluator(match);
inputReplacement.Remove(match.Index + replacementLengthDifference, match.Length);
inputReplacement.Insert(match.Index + replacementLengthDifference, replacement);
replacementLengthDifference += replacement.Length - match.Length;
}
return inputReplacement.ToString();
}