Thursday, 8 November 2018

Verify that Strings Are in Valid Email Format

 public static bool isEmail(string pStrInputEmail)
 {
            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(pStrInputEmail))
            {
                return (true);
            }
            else
            {
                return (false);
            }
}

No comments:

Post a Comment