Expression régulière: verfier si un email est correct

Author:


{filelink=18791}


using System;
using System.Text.RegularExpressions;

    public class EmailSyntaxe
    {
        public static bool estEmailCorrect(string inputEmail)
        {
            bool resultat = false;
            try
            {
                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))
                {
                    resultat = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return resultat;
        }
        public static void Main(string[] argv)
        {

            Console.WriteLine(estEmailCorrect("demokoi@yahoo.com"));

        }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *