I have read many times over about the virtue of using Stringbuilder vs. string when multiple replacements are needed. I need to convert an HTML string (all very simple formatting) to WIKI notation and was going to roll my own from code I found on SO. I'm wondering if there is a simpler way to do this, and also how I can implement the benefits of a StringBuilder with it. All my attempts til now have failed miserably. Please advise and thank you in advance.
public static string ConvertHTML2WIKInotation(string htmlstring)
{
StringBuilder sb = new StringBuilder(htmlstring);
htmlstring = ReplaceInsensitive(htmlstring, "<hr>", "----");
htmlstring = ReplaceInsensitive(htmlstring, "<hr />", "----");
... etc.
return sb.ToString();
}
static public string ReplaceInsensitive(this string str, string from, string to)
{
str = Regex.Replace(str, from, to, RegexOptions.IgnoreCase);
return str;
}