简体   繁体   English

用于电子邮件的正则表达式无法验证高级域中的数字

[英]Regex for email not validating numbers in the high level domain

 private const string EmailPattern = @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z";

I am able to validate most of the emails correctly but one of the condition that I want to validated is numeric digit at the end of the high level domain. 我能够正确验证大多数电子邮件,但我要验证的条件之一是高级域末尾的数字。 eg : abc@test.com1 (I dont think this is a valid email and want to validate this condition) 例如:abc@test.com1(我认为这不是有效的电子邮件,想验证此条件)

There are lot of regex tht I have tried but no success. 我尝试过很多正则表达式,但没有成功。

试试这个正则表达式

^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM