Sunday, July 15, 2007

Code Snippet - Email Validation using Reg. Exp (C#)

public

bool IsEmail(string inputEmail)

{

string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +

@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +

@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

Regex re = new Regex(strRegex);

if (re.IsMatch(inputEmail))

return (true);

else

return (false);

}

0 comments: