Stripping HTML Tags
This is my first post in this blog. I hope you find
useful.
One of common problem for web developers is
"stripping html tags".
in example : in search
operations or sending plain text emails by newsletter and
.....
in this post i do that with
RegularExpressions.
private string StripHtmlTags(string html)
{
string plainText = Regex.Replace(html, @"<(.|\n)*?>", string.Empty);
plainText = plainText.Replace("\t", " ");
plainText = plainText.Replace("\r\n", string.Empty);
//Remove extra blank spaces
plainText = Regex.Replace(plainText, " +", " ");
return plainText;
}