-
-
Save markhowellsmead/48f4f62acd7f75afaceaffab430c0345 to your computer and use it in GitHub Desktop.
^([\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})(\]?)$ |
Thanks @nitheesh! According to https://www.icann.org/en/system/files/files/ua-factsheet-a4-17dec15-en.pdf, the maximum length of a TLD is 63 characters. The following snippet will cover that.
^([\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,63}|\d{1,3})(\]?)$
Thank you for sharing, do you know how to make it not case sensitive? For example if I type xxxx@Gmail.com validation doesn't work.
@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
Thanks for this snippet. we need to update the TLD length on the 6th capturing group to at least 10-15 charectors to match the TLD like .agency, .productions, .photography, etc
^([\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,15}|\d{1,3})(\]?)$