验证邮箱格式

class Program
    {
        static void Main(string[] args)
        {
            string s = "1033628976@qq.com";
            if (Yzmail(s) == true)
            {
                Console.WriteLine("邮箱格式正确!");
            }
            else
            {
                Console.WriteLine("邮箱格式错误!");
            }
        }
        public static bool Yzmail(string s)
        {
            Regex regex = new Regex(@"^[\w-.]+@([\w-]+\.)+[\w]{2,4}$");
            return regex.IsMatch(s);
            
        }
    }

posted @ 2016-09-12 09:33  马战强777  阅读(199)  评论(1)    收藏  举报