Tag Archives: c# – How can I strip HTML tags from a string in ASP.NET

Remove HTML tags from string in c#

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, “”);



string title = rx.Replace(dr1[“Title”].ToString(), “”); ;
if (title.Length > 34)
newstitle.Text = title.Substring(0, 34) + “…”;
newstitle.Text = title;


//now str contains string without html tags like that

Welcome to parse text humrahimcs blog


Leave a comment

Posted by on May 24, 2013 in ASP Dot Net C#


Tags: , , ,