Regular Expression to validate email ending in .edu

I am trying to create a regex validation attribute in asp.net mvc to validate that an entered email has the .edu TLD. I have tried the following but the expression never validates to true... [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+edu and w.w@{1,1}w[.w]?.edu Can anyone provide some insight? This should work for you: ^[a-

正则表达式来验证以.edu结尾的电子邮件

我正在尝试在asp.net mvc中创建一个正则表达式验证属性,以验证输入的电子邮件是否具有.edu TLD。 我已经尝试过以下但表达式从不验证为真... [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+edu 和 w.w@{1,1}w[.w]?.edu 谁能提供一些见解? 这应该适合你: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.+-]+.edu$ 自从你在RegEx表现出你很弱, ^字符串的开始 [

MailAddress with single

Possible Duplicate: What characters are allowed in email address? In C#, I don't know why MailAddress accept email address with single-quote, eg 'a''a'@gmail.com ... I also tested it in Hotmail and Gmail websites and they'll allow me to send an email to this wrong email addresses, but of course, later will get an failure email... even though during sign up, it doesn

MailAddress与单个

可能重复: 电子邮件地址允许使用哪些字符? 在C#中,我不知道为什么MailAddress接受带单引号的电子邮件地址,例如'a''a'@gmail.com ...我也在Hotmail和Gmail网站上测试过它们,他们将允许我发送发邮件给这个错误的电子邮件地址,但当然,以后会收到失败的电子邮件......即使在注册时,它也不允许带有单引号'新电子邮件' ...您是否知道一个有效的电子邮件地址-引用? 它是有效的格式? 对不起,

Get email address from the url with and without escape character of @ in c#

I have a Url as shown below http://www.mytestsite.com/TesPage.aspx?pageid=32&LangType=1033&emailAddress=myname%40gmail.com I would like to have the email address from the url Note The email address may have the escape character of @ sometimes. ie it may be myname%40gmail.com or myname@gmail.com Is there any way to get the email address from a url, such that if the that have th

从URL中获取电子邮件地址,在c#中使用或不使用@的转义字符

我有一个Url,如下所示 http://www.mytestsite.com/TesPage.aspx?pageid=32&LangType=1033&emailAddress=myname%40gmail.com 我想从网址获取电子邮件地址 注意 电子邮件地址可能有@的转义字符。 即它可能是myname%40gmail.com或myname@gmail.com 有没有什么办法从网址获取电子邮件地址,例如,如果电子邮件地址的匹配regx为regten并检索值。 这是我试过的代码 string theRealURL = "http://www.mytestsit

EmailAttribute is not validating correctly in a ViewModel from ASP.NET Core

This is a field located in my viewmodel: [Required(ErrorMessage = "Email is missing."), EmailAddress(ErrorMessage = "Email is not valid.")] public string Email { get; set; } ( EmailAddress is from the EmailAddressAttribute.EmailAddressAttribute() type) This is the relevant part from the HTML: <div> <label for="inputEmail">EMAIL</label> <input id="inputEmail" ng-m

EmailAttribute在ASP.NET Core的ViewModel中未正确验证

这是一个位于我的视图模型中的字段: [Required(ErrorMessage = "Email is missing."), EmailAddress(ErrorMessage = "Email is not valid.")] public string Email { get; set; } ( EmailAddress来自EmailAddressAttribute.EmailAddressAttribute()类型) 这是来自HTML的相关部分: <div> <label for="inputEmail">EMAIL</label> <input id="inputEmail" ng-model="email" asp-for="Email" c

How to check if email is valid format or not

The below email is not valid format fulya_42_@hotmail.coö But all validations i found and tried so far with c# said it is correct email which is not How can i validate email is valid or not with c# 4.5.2? thank you Ok updated question The reason i am asking is one of the biggest email service mandrill api throws internal server error when you try to email this address So they must be u

如何检查电子邮件是否为有效格式

以下电子邮件无效格式 fulya_42_@hotmail.coö 但是,我发现和迄今为止与c#一起尝试的所有验证都表示这是不正确的电子邮件 我如何验证电子邮件是否有效或不与C#4.5.2? 谢谢 确定更新的问题 我想问的原因是最大的电子邮件服务mandrill api之一,当您尝试通过电子邮件发送此地址时抛出内部服务器错误 所以他们必须在尝试发送电子邮件之前使用某种验证。 我的目标是找到他们用来消除这些电子邮件之前尝试感谢你 通过

In C# windows forms how a MaskedTextBox for email address can be implemented

public void Form1_Load(Object sender, EventArgs e) { // Other initialization code mtxtEmailID.Mask = ".........."; what should be the Mask Type in place of dots mtxtEmailID.MaskInputRejected += new MaskInputRejectedEventHandler(mtxtEmailID_MaskInputRejected) } void mtxtEmailID_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) { i

在C#窗口窗体中,可以如何实现用于电子邮件地址的MaskedTextBox

public void Form1_Load(Object sender, EventArgs e) { // Other initialization code mtxtEmailID.Mask = ".........."; Mask Type代替点应该是什么 mtxtEmailID.MaskInputRejected += new MaskInputRejectedEventHandler(mtxtEmailID_MaskInputRejected) } void mtxtEmailID_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) { if(!Regex.IsMatch(txt

Email address input validation

Is there any way to make a textbox input validation for email addresses in wpf C#? Regex or validation expression or anything that can help, best with code sample and some instructions On the text_changed event you could pass the value of the textbox to a helper class. public static class ValidatorExtensions { public static bool IsValidEmailAddress(this string s) { Regex regex

电子邮件地址输入验证

有没有办法在wpf C#中的电子邮件地址进行文本框输入验证? 正则表达式或验证表达式或任何可以提供帮助的东西,最好使用代码示例和一些说明 在text_changed事件上,您可以将文本框的值传递给帮助器类。 public static class ValidatorExtensions { public static bool IsValidEmailAddress(this string s) { Regex regex = new Regex(@"^[w-.]+@([w-]+.)+[w-]{2,4}$"); return regex.IsMatch(s);

Why can't I reference System.ComponentModel.DataAnnotations?

I'm trying to use DataAnnotations in my WPF project to specify a maximum length of strings, with the following: using System.ComponentModel.DataAnnotations; However, I get the error The type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?) I've seen other examples where DataAnnotation

为什么我不能引用System.ComponentModel.DataAnnotations?

我想在我的WPF项目中使用DataAnnotations来指定字符串的最大长度,具体如下: using System.ComponentModel.DataAnnotations; 但是,我收到错误 名称空间“System.ComponentModel”中不存在类型或名称空间名称“DataAnnotations”(您是否缺少程序集引用?) 我已经看到了DataAnnotations存在于这个名字空间中的其他例子。 我正在使用C#4。 我有什么理由不能使用它? 我能做些什么来解决它? 您必须引用定义了此名称空间

Making email address a@b.c not pass validation?

This question already has an answer here: C# code to validate email address 34 answers Can I check if an email address exists using .net? 6 answers You can't do this without a DNS lookup. a@bc passes the RFC rules for email formats. If you want to use RegEx, you can use the following, which is false for a@bc You would need to keep it up to date with the valid current domains, and

使电子邮件地址a @ bc未通过验证?

这个问题在这里已经有了答案: 验证电子邮件地址的C#代码34个答案 我可以使用.net来检查电子邮件地址是否存在吗? 6个答案 没有DNS查询,你无法做到这一点。 a @ bc通过了电子邮件格式的RFC规则。 如果您想使用RegEx,则可以使用以下内容,对于@ bc这是错误的 您需要及时更新有效的当前域名,并且没有检查就没有实际存在的保证。 private static bool ValidEmail(string emailAddress) { var regex = new Regex(

How to handle long email address with regex?

This question already has an answer here: C# code to validate email address 34 answers You can use the MailAddress class to validate the email instead of validating it using the regex. MailAddress m = new MailAddress(email); From MSDN Instead of using a regular expression to validate an email address, you can use the System.Net.Mail.MailAddress class. To determine whether an email addres

如何使用正则表达式处理长电子邮件地址?

这个问题在这里已经有了答案: 验证电子邮件地址的C#代码34个答案 您可以使用MailAddress类来验证电子邮件,而不是使用正则表达式对其进行验证。 MailAddress m = new MailAddress(email); 来自MSDN 您可以使用System.Net.Mail.MailAddress类,而不是使用正则表达式来验证电子邮件地址。 要确定电子邮件地址是否有效,请将该电子邮件地址传递给MailAddress.MailAddress(String)类构造函数。