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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details 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
   Displaying page 1 of 1 pages; Items 1 to 1

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