RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Disallow HTML code
Expression
^[^<^>]*$
Description
I use this one as a simple way to disallow HTML code in form fields. It simply doesn't allow the use of the &lt; and &gt; characters. It does, however, allow the entities for these characters (&amp;lt; and &amp;gt;), which will print the characters to the screen appropriately, if needed. I'm sure there are more complex expressions to block HTML, but none more concise.
Matches
hello world, &amp;lt;b&amp;gt;Hello World&lt;/b&gt;
Non-Matches
<b>Hello World</b>
Author Rating: Not yet rated. Doug Gainey
Source Doug Gainey
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials