Question: I am using the following Regular Expresion to remove html tags from a string. It works except I leave the closing tag. If I attempt to remove: `<a href="blah">blah</a>` it leaves the `<a/>`.

I do not know Regular Expression syntax at all and fumbled through this. Can someone with RegEx knowledge please provide me with a pattern that will work.

Here is my code:

```
  string sPattern = @"<\/?!?(img|a)[^>]*>";
  Regex rgx = new Regex(sPattern);
  Match m = rgx.Match(sSummary);
  string sResult = "";
  if (m.Success)
   sResult = rgx.Replace(sSummary, "", 1);

```

I am looking to remove the first occurence of the `<a>` and `<img>` tags.

Answer: 
You can use already existing libraries to strip off the html tags. One good one being [Chilkat C# Library](http://www.example-code.com/csharp/html2xml.asp).
Here's an extension method I created using a simple regular expression to remove HTML tags from a string:

```
/// <summary>
/// Converts an Html string to plain text, and replaces all br tags with line breaks.
/// </summary>
/// <returns></returns>
/// <remarks></remarks>
[Extension()]
public string ToPlainText(string s)
{

    s = s.Replace("<br>", Constants.vbCrLf);
    s = s.Replace("<br />", Constants.vbCrLf);
    s = s.Replace("<br/>", Constants.vbCrLf);

    s = Regex.Replace(s, "<[^>]*>", string.Empty);

    return s;
}

```

Hope that helps.