string MatchFormat(string subject, string sample, string color)
{
if (string.IsNullOrEmpty(sample))
return subject;
sample = Regex.Escape(sample);
return Regex.Replace(subject, sample, m => $"<color={color}>{m.Value}</color>");
}
I'd like to only replace the first found occurrence of sample
with m => $"<color={color}>{m.Value}</color>"
. How can I do this?