", "", RegexOptions.IgnoreCase | RegexOptions.Singleline);
// Replace special characters like &, <, >, " etc.
StringBuilder sbHTML = new StringBuilder(htmlCode);
// Note: There are many more special characters, these are just
// most common. You can add new characters in this arrays if needed
string[] OldWords = {" ", "&", """, "<", ">", "®", "©", "•", "™","'"};
string[] NewWords = { " ", "&", "\"", "<", ">", "®", "©", "•", "™", "\'" };
for (int i = 0; i < OldWords.Length; i++) {
sbHTML.Replace(OldWords[i], NewWords[i]);
}
// Check if there are line breaks (
) or paragraph ()
sbHTML.Replace("
", "\n
");
sbHTML.Replace("
]*>", "");
// Remove external new lines
plainText = plainText.Trim();
return plainText;
}
}
}