Last active
October 30, 2024 10:39
-
-
Save markhowellsmead/48f4f62acd7f75afaceaffab430c0345 to your computer and use it in GitHub Desktop.
Regex for valid email address excluding specific free domains, like Gmail, GMX and Yahoo. Extend the list of domains according to your own requirements.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^([\w.-]+)@(\[(\d{1,3}\.){3}|(?!hotmail|gmail|googlemail|yahoo|gmx|ymail|outlook|bluewin|protonmail|t\-online|web\.|online\.|aol\.|live\.)(([a-zA-Z\d-]+\.)+))([a-zA-Z]{2,4}|\d{1,3})(\]?)$ |
@alexk1350 A regular modifier for case-insensitivity should be sufficient.
Got it, honestly, I'm not an expert in Regex, snipped you have released is almost perfect, worked well with our CMS. Will start to torture my backend devs:) have no idea what is "A regular modifier for case-insensitivity ". Thank you for making it public!
It depends which technology you're using. E.g. for PHP look at flags
in preg_match
.
.net What you have hear "^([\w.-]+)@([(\d{1,3}.){3}|(?!hotmail|gmail|googlemail|yahoo|gmx|ymail|outlook|bluewin|protonmail|t-online|web.|online.|aol.|live.)(([a-zA-Z\d-]+.)+))([a-zA-Z]{2,4}|\d{1,3})(]?)$" works well with exception of case sensitivity. gMail, oUtlook etc. Thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing, do you know how to make it not case sensitive? For example if I type [email protected] validation doesn't work.