开发者

Restrict this regex to "edu", top-level domain

开发者 https://www.devze.com 2023-03-29 19:41 出处:网络
I have this regex that checks the validity of an email address var reg = /^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4})开发者_开发技巧$/;

I have this regex that checks the validity of an email address

var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})开发者_开发技巧$/;

I want to tweak it so it ensures the email address entered is an .edu account.

PS - It's not for homework, I swear.


Change ([A-Za-z]{2,4}) into [Ee][Dd][Uu].


var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.[Ee][Dd][Uu]$/;


var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.(edu)$/i;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号