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:
Breakdown since you said you were weak at RegEx:
^Beginning of string[a-zA-Z0-9._%+-]+one or more letters, numbers, dots, underscores, percent-signs, plus-signs or dashes@@[a-zA-Z0-9.+-]+one or more letters, numbers, dots, plus-signs or dashes\.edu.edu$End of string