Possible Duplicate:
Validating an email Address in C#
Hi,
I'm trying to create regular expression to check valid email address, but the following code not returning any output.
foreach(Match m in (Regex.Matches("Jack@yahoo.com","^([a-zA-Z])+(?:\\d)*?@\\1\\.\\1{2,4}$")))
{
Console.WriteL开发者_高级运维ine("{0} found at index{1}",m.Value,m.Index);
}
Could anyone please tell what's wrong I'm doing?
Try this
foreach(Match m in (Regex.Matches("Jack@yahoo.com","^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$")))
{
Console.WriteLine("{0} found at index{1}", m.Value, m.Index);
}
精彩评论