开发者

RegEx'ing Hotmail email addresses with C#

Unfortunately my开发者_Python百科 hMailServer can't send emails to Hotmail. How can I determine whether a given email address is Hotmail or not, to prevent the message from being lost.

Hotmail e-mails can be: * @live.com * @live.fr[pt][ru][etc] * @hotmail.com, * @live.com.jp * @msn.com * and many country TLD specific combinations involving MSN, Hotmail and Live.

It seems like it's impossible to use a regular expression to filter that.

Any ideas on how to detect whether an email addresses is in the Hotmail family of addresses?


This will work:

function bool IsHotmailAddress(string email) {
    var r = new Regex(@"\@(live|hotmail)\.[a-z]{2,3}(\.[a-z]{2,3})?$", RegexOptions.IgnoreCase);
    return r.IsMatch(email);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜