电子邮件正则表达式,它包括Unicode域名 [英] Email Regex that DOES include unicode domains

查看:215
本文介绍了电子邮件正则表达式,它包括Unicode域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人发现,验证,其中包括Unicode字符作为从一个Unicode域的电子邮件的解决方案?我寻觅的长度,还没有找到一个可行的解决方案。

I was wondering if anybody has found a solution that validates an email that includes unicode characters as in from a unicode domain? I have searched at length and have yet to find a solution that works.

推荐答案

我有同样的问题,并与上前智能解决方案 \p {L}
请检查出来:

I had the same issue and came up with an intelligent solution \p{L}. Please check it out:

private static bool IsEmailValid(string email) {
    System.Text.RegularExpressions.Regex re = new Regex(@"^[\p{L}0-9!$'*+\-_]+(\.[\p{L}0-9!$'*+\-_]+)*@[\p{L}0-9]+(\.[\p{L}0-9]+)*(\.[\p{L}]{2,})$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);

    return re.IsMatch(email);
}

这篇关于电子邮件正则表达式,它包括Unicode域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆