Remove HTML tags from string. Some time you need to parse some string which is received by some responses like Httpresponse from the server. or when you enter from admin side in the form of htmleditor/html
then you need to show some where only plain text in short then you follow …
string str = “<html><head>Welcome to parse text</head><body><b>humrahimcs blog</b></body></html>”;
// regex which match tags
System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex(“<[^>]*>”);
// replace all matches with empty strin
str = rx.Replace(str, “”);
or
string title = rx.Replace(dr1[“Title”].ToString(), “”); ;
if (title.Length > 34)
{
newstitle.Text = title.Substring(0, 34) + “…”;
}
else
{
newstitle.Text = title;
}
//now str contains string without html tags like that
Welcome to parse text humrahimcs blog