Thursday, February 6, 2014

C# Is Email Function

The following snippet is handy when validating if a given string is an email address.
public static bool IsEmail(string emailAddress)
        {
            Regex isEmail = new Regex(@"\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$");
            Match m = isEmail.Match(emailAddress);
            return m.Success;
        }

No comments:

Post a Comment