js正则表达式之邮箱格式

js正则表达式之邮箱格式

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title></head><body><script>/*** 电子邮件*  154hello   .abc        @       abc      .com.cn** \w{3,}  (\.\w+)*     @      [A-z0-9]+  (\.[A-z]{2,5}){1,2}** \w{3,}:任意字母或数字至少3个* (\.\w+)*:.加任意字符或数字至少一个,整体可有可无,0或多个* @:一定要有@* [A-z0-9]+:任意字母或数字至少1个* (\.[A-z]{2,5}){1,2}: .加任意字符2到5个,整体1到2个*///邮箱正则let emailReg = /^\w{3,}(\.\w+)*@[A-z0-9]+(\.[A-z]{2,5}){1,2}$/; //注意中间不能有空格let email = prompt("请输入邮箱", "abc21345.hello@qq.com");let res = emailReg.test(email);res ? alert("邮箱格式正确") : alert("邮箱格式错误");</script></body>
</html>

本文链接:https://my.lmcjl.com/post/15420.html

展开阅读全文

4 评论

留下您的评论.