Developers Heaven Forum

Desktop Programming => .NET Programming => ASP.NET => Topic started by: admin on August 28, 2008, 08:54:54 AM

Title: Converting HTML to Text using C# ASP.NET
Post by: admin on August 28, 2008, 08:54:54 AM
Hello all,
did you think before how to convert HTML to Text and remove all HTML tags?
it is so easy using the Regular Expressions in the DOT NET, all you need is the following function :)
hoping to see your comments.


Code: [Select]

private string StripTags(string HTML)
        {
            // Removes tags from passed HTML           
            System.Text.RegularExpressions.Regex objRegEx = new System.Text.RegularExpressions.Regex("<[^>]*>");

            return objRegEx.Replace(HTML, "");
        }