You want to validate a common user-submitted value contained in a string, such as an e-mail address, date, or user name.
Create the System.Text.RegularExpressions.Regex class with the appropriate regular expression, and call the IsMatch method with the value you want to test. Make sure to include the
^ characters in your expression so that you match the entire string.
Although creating a regular expression can be difficult, applying one is not. You simply need to create a Regex instance, supply the regular expression in the constructor, and then test for a match. The following code example verifies an e-mail address using a regular expression from Table 1-2. In order for it ...