You can see a regular expression validator at work in the ValidationControls example on the CD-ROM and in Figure 18.7. Here, the code is checking to make sure the users have entered a valid email address—and because they have not, the regular expression validator is displaying an error message as you see in that figure.
As with other validation controls, you set the ControlToValidate property to set the control whose data you want to validate, and place the error message in the ErrorMessage property. To set the regular expression to use, you use the ValidationExpression property, and Visual Basic lets you choose from some preset regular expressions in the Regular Expression Editor you see in Figure 18.8, which opens when you click the ValidationExpression property in the properties window.
In the ValidationControls example, I use this regular expression to match email addresses:
And that's all it takes. In general, creating regular expressions yourself is not the easiest task, but you can get used to working with them. For a complete treatment of regular expressions, showing how to create them in detail, see the Coriolis Perl Black Book.