Check Email by Regex - CSharp System.Text.RegularExpressions

CSharp examples for System.Text.RegularExpressions:Match Email

Description

Check Email by Regex

Demo Code


using System.Web;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System;//from ww w. j ava2  s. com

public class Main{
        public static bool CheckEmail(string email)
        {
            Regex  re = new Regex("[a-zA-Z0-9\\-\\.]+@(([a-zA-Z0-9\\-]+\\.)+([a-zA-Z0-9]{2,4})+$)", RegexOptions.None);
            Match m = re.Match(email);
            if (m.Success)
                return true;
            else
                return false;
        }
}

Related Tutorials