1. Computing

Using Regular Expressions in ASP.NET

From , former About.com Guide

1 of 7

The Intersection of Regular Expressions and ASP.NET
RegEx Server and Client Validation

The Complete RegEx Server and Client Validation

About Visual Basic has featured articles about how to use Regular Expressions - Introduction to Regular Expressions in Visual Basic. Reguar Expressions can be confusing, even though they're a powerful technique and the RegularExpressionValidator control for ASP.NET makes the two together an even more powerful combination.

(Note ... I will use the shorthand "regex" to mean "regular expression" in the remainder of this article.)

The other ASP.NET validation controls let you check for required values, comparisons and ranges, and even provide the ability to code any validation that you like in a custom event handler called by ASP.NET. But since validation is really checking text, and regexes are the premier way to check text, the RegularExpressionValidator control is just a natural fit!

The basic idea behind using the RegularExpressionValidator control is to add the control to a web form that also contains the control to be validated. Add the ID of the control to be validated and the actual regex code to the ValidationExpression property of the RegularExpressionValidator control ... and you're good to go! This does "Server Side" validation. You can also validate with client script and I'll show you a simple example after we get the initial application working.

  1. About.com
  2. Computing
  3. Visual Basic
  4. Learn VB.NET
  5. Learn ASP.NET
  6. Using Regular Expressions in ASP.NET

©2013 About.com. All rights reserved.