当前位置: 移动技术网 > IT编程>开发语言>c# > C# regular expression to validate email

C# regular expression to validate email

2019年09月08日  | 移动技术网IT编程  | 我要评论
using system;
using system.text.regularexpressions;

namespace consoleapp375
{
    class program
    {
        static void main(string[] args)
        {
            regularexpressiondemo();
            console.readline();
        }

        static void regularexpressiondemo()
        {
            string emailpattern = @"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*@((([\-\w]+\.)+[a-za-z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))\z";
            regex regex = new regex(emailpattern);
            string mymail = "aaa@163.com";
            var match = regex.match(mymail);
            console.writeline(match.success);
        }
    }
}

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网