C# regular expression to validate email
2021-02-04 03:15
标签:ogr nbsp string app expr style col pac namespace C# regular expression to validate email 标签:ogr nbsp string app expr style col pac namespace 原文地址:https://www.cnblogs.com/Fred1987/p/11485676.htmlusing 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);
}
}
}
文章标题:C# regular expression to validate email
文章链接:http://soscw.com/index.php/essay/50708.html