The RegularExpression Validator control offers a lot of flexibility when you apply validation rules to your Web Forms. You can check a user’s input based on a pattern that you define using a regular expression. This means that you can define a structure that a user’s input will be applied against to see whether its structure matches the one that you define. For example, you can define that the structure of the user input must be in the form of an e-mail address or an Internet URL; if it does not match this definition, then an error will occur.
The unique property of this validation control is the ValidationExpression property. This property takes a string value, which is the regular expression you are going to apply to the input value.
Visual Studio makes using regular expressions a little easier through the use of the Regular Expression Editor. This editor provides a few commonly used regular expressions that you might want to apply to your RegularExpressionValidator. To get at this editor, you work with your page from the Design view. Be sure to highlight the RegularExpressionValidator1 server control in this Design view to see the control’s properties. In the Property window of Visual Studio, click the button found next to the ValidationExpression property to launch the Regular Expression Editor. Using this editor, you can find regular expression for things like e-mail addresses, Internet URLs, ZIP codes, Phone numbers and Social Security numbers.