23 Jun

C# Email Validation With Regular Expression

This example shows how to validate an email address using regular expression.

Sample Usage:

            Regex regEx = new Regex("^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$");
            bool result = regEx.IsMatch("admin@csharexamples.com");
            //result = true

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Your IP has been flagged as spam/malicious.