Is Email by Regex - CSharp System.Text.RegularExpressions

CSharp examples for System.Text.RegularExpressions:Match Email

Description

Is Email by Regex

Demo Code


using System.Text.RegularExpressions;

public class Main{
        public static bool IsEmail(string input)
        {//w ww.  jav a  2  s .  c  o  m
            if (!string.IsNullOrEmpty(input))
            {
                string EmailReg = @"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$";

                return Regex.IsMatch(input, EmailReg, RegexOptions.IgnoreCase);
            }
            return false;
        }
}

Related Tutorials