Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Created August 7, 2013 15:59
Show Gist options
  • Save csharpforevermore/6175435 to your computer and use it in GitHub Desktop.
Save csharpforevermore/6175435 to your computer and use it in GitHub Desktop.
In ASP.NET MVC 4, using the Entity Framework (code first) approach, I needed to create a RegEx for emails - allowing uppercase or lowercase. This was the solution for me.
[Required]
[RegularExpression(@"\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b", ErrorMessage = "Invalid email address")]
[DisplayName("E-mail addresss")]
public string Email { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment