1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
public static class TestEmail { /// <summary> /// Regular expression, which is used to validate an E-Mail address. /// </summary> public const string MatchEmailPattern = @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@" + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]? [0-9]{1,2}|25[0-5]|2[0-4][0-9])\." + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]? [0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|" + @"([a-zA-Z0-9]+[\w-]+\.)+[a-zA-Z]{1}[a-zA-Z0-9-]{1,23})$"; /// <summary> /// Checks whether the given Email-Parameter is a valid E-Mail address. /// </summary> /// <param name="email">Parameter-string that contains an E-Mail address.</param> /// <returns>True, when Parameter-string is not null and /// contains a valid E-Mail address; /// otherwise false.</returns> public static bool IsEmail(string email) { if (email != null) return Regex.IsMatch(email, MatchEmailPattern); else return false; } } |
참조 : http://www.codeproject.com/Articles/22777/Email-Address-Validation-Using-Regular-Expression