<p>Does anyone have a simple, efficient way of checking that a string doesn't contain HTML?  Basically, I want to check that certain fields only contain plain text.  I thought about looking for the &lt; character, but that can easily be used in plain text.  Another way might be to create a new System.Xml.Linq.XElement using:</p>

<pre><code>XElement.Parse("&lt;wrapper&gt;" + MyString + "&lt;/wrapper&gt;")
</code></pre>

<p>and check that the XElement contains no child elements, but this seems a little heavyweight for what I need.</p>

The following will match any matching set of tags. i.e. <b>this</b>
```
```
Regex tagRegex = new Regex(@"<\s*([^ >]+)[^>]*>.*?<\s*/\s*\1\s*>");
```
```
The following will match any single tag. i.e. <b> (it doesn't have to be closed).
```
```
Regex tagRegex = new Regex(@"<[^>]+>");
```
```
You can then use it like so
```
```
bool hasTags = tagRegex.IsMatch(myString);
```
```