c#中如何用代码验证是否电子邮件(用正则) _爱资料
主页 > 编程资料 > C# >
发布时间:2015-09-26 作者:网络 阅读:178次
1.引用名称空间
using System.Text.RegularExpressions;
2.代码:

string strInput="aaa@163.com";
string strExp=@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
// Create a new Regex object.
Regex r = new Regex(strExp);
// Find a single match in the string.
Match m = r.Match(strInput);
if (m.Success)
{
MessageBox.Show("验证成功!");
}

关键字词: