What I want to do is to replace a part of the text inside the clipboard, but the problem is it is html formatted text and I am unable to modify its content using the below given code in C#. Any solutions?
Steps to replicate my doing:
1- copy an entry from cambridge advanced learner dictionary 4 to clipboard OR any other html formatted text to clipboard
2- Use these C# codes in a windows forms application to modify and replace text while keeping its html formatting:
private void button1_Click(object sender, EventArgs e)
{
string myStr = Clipboard.GetText(TextDataFormat.Html);
myStr.Replace("Cambridge Advanced Learner's Dictionary - 4th Edition", "******************************");
Clipboard.SetText(myStr,TextDataFormat.Html);
}
But it seems that it does not work at all!
NOTE: I want to keep the html formatting, I don't want to strip string from its html formatting.
I used Regex and it seems to work when I use:
myStr = Regex.Replace(myStr, "Cambridge Advanced Learner's Dictionary - 4th Edition", "");
but when I want to use:
myStr = Regex.Replace(myStr, "Cambridge Advanced Learner's Dictionary - 4th Edition<br /><br />", "");
it does not work! any solutions to remove those html tags: <br /><br />
?