How to remove html tags from string with Regular Expressions

By Emanuele Bartolesi at October 27, 2009 15:53
Filed Under: C#

This evening I created a project in C# that explains how to remove html tags from string with regular expressions.

I created a function to semplify this operation.

        private string removeHmtlFromString(string strInput)
        {
            try
            {
                Regex objRegExp = new Regex("<(.|\n)+?>");
                return objRegExp.Replace(strInput, String.Empty).Trim();
            }
            catch
            {
                return string.Empty;
            }
        }

You can download the full work project from this article.

RemoveHtmlFromString.rar (36.17 kb)

Comments

10/28/2009 3:13:16 PM #

Trackback from DotNetKicks.com

How to remove html or xml tags from string with Regular Expressions

DotNetKicks.com

About me

I will also give you some useful tips, based on the modest wisdom gained during the years that I've worked as a developer and project manager.

Widget

Ohloh profile for Emanuele Bartolesi

 

Wakoopa

Software tracking

 

Software tracking

from Amazon



hacker emblem



Scarica il pdf di Game
Rivista Game di videogiochi
Trucchi videogiochi