js regular expression & email checker


const isValidEmail = (email = ``) => /^([\w+\.])+@(\w+)([.]\w+)+$/ig.test(email);
function isValidEmail(email = ``) {
return /^([\w+\.])+@(\w+)([.]\w+)+$/ig.test(email);
}

test


email = `wwW@com.xyz`;
"wwW@com.xyz"
/^([\w+\.])+@(\w+)([.]\w+)+$/ig.test(email)
true
email = `ww.W@com.xyz.abc`;
"ww.W@com.xyz.abc"
/^([\w+\.])+@(\w+)([.]\w+)+$/ig.test(email)
true
email = `ww.W@@com.xyz.abc`;
"ww.W@@com.xyz.abc"
/^([\w+\.])+@(\w+)([.]\w+)+$/ig.test(email)
false
email = `ww.W@com.xyz.abc..ufo`;
"ww.W@com.xyz.abc..ufo"
/^([\w+\.])+@(\w+)([.]\w+)+$/ig.test(email)
false
email = `ww.W@com.xyz.abc.nba.ufo`;
"ww.W@com.xyz.abc.nba.ufo"
/^([\w+\.])+@(\w+)([.]\w+)+$/ig.test(email)
true

Regular Expressions & Cheatsheet

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet#Character_classes

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes

\w & \W

基本的拉丁字母,包括下划线

\w === [A-Za-z0-9_]

\W === [^A-Za-z0-9_]

\d & \D

阿拉伯数字

\d === [0-9]

\D === [^0-9]

\s & \S

匹配单个空格字符,包括空格,制表符,换页符,换行符和其他Unicode空格。

\s === [ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]

\S === [^A-Za-z0-9_]

\b & \B

边界字符检测

// 前,后
\b // 前,后
\B

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet#Assertions

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Assertions

Group

分组


Range

范围


https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet#Groups_and_ranges

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Groups_and_Ranges

Quantifiers

量词


https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet#Quantifiers

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Quantifiers

refs

https://regexper.com/

Regular Expression

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet

https://www.nowcoder.com/ta/front-end



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


js regular expression & email checker的更多相关文章

  1. myeclipse中导入js报如下错误Syntax error on token "Invalid Regular Expression Options", no accurate correc

    今天在使用bootstrap的时候引入的js文件出现错误Syntax error on token "Invalid Regular Expression Options", no ...

  2. RegexKit: A Regular Expression Toolbox Based On NW.js(Node-Webkit) And Other Greate Open Source Projects.

    RegexKit RegexKit: A Regular Expression Toolbox Based On NW.js(Node-Webkit) And Other Greate Open So ...

  3. js文件报错Syntax error on token "Invalid Regular Expression Options", no accurate correction

    Syntax error on token "Invalid Regular Expression Options", no accurate correction 1.选中报错的 ...

  4. ----regular expression in js----

    正则表达式:Regular Expression,在代码中常简写为regex.regexp或RE)使用单个字符串来描述.匹配一系列符合某个句法规则的字符串搜索模式. 搜索模式可用于文本搜索和文本替换. ...

  5. 【 Regular Expression Matching 】cpp

    题目: Implement regular expression matching with support for '.' and '*'. '.' Matches any single chara ...

  6. Python中的正则表达式regular expression

    1 match = re.search(pat,str)  If the search is successful, search() returns a match object or None o ...

  7. Spring EL regular expression example

    Spring EL supports regular expression using a simple keyword "matches", which is really aw ...

  8. 10. Regular Expression Matching *HARD*

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  9. Syntax error on token "Invalid Regular Expression Options", no accurate corr

    今天导入项目一个js文件报这个错 Syntax error on token "Invalid Regular Expression Options", no accurate c ...

随机推荐

  1. Exception 异常处理

    https://github.com/jazzband/django-redis/blob/master/django_redis/exceptions.py django-redis/base.py ...

  2. xss靶场详解

    一个XSS靶场练习记录 https://blog.csdn.net/qq_41500251/article/details/101116697 001.level 1 反射型 1.观察源码 <s ...

  3. Codeforces 1220D 思维 数学 二分图基础

    原题链接 题意 我们有一个含多个正整数的集合B,然后我们将所有的整数,也就是Z集合内所有元素,都当做顶点 两个整数 \(i , j\) 能建立无向边,当且仅当 \(|i - j|\) 这个数属于B集合 ...

  4. Spring Boot 系列总结

    Spring Boot 系列总结 1.SpringBoot自动装配 1.1 Spring装配方式 1.2 Spring @Enable 模块驱动 1.3 Spring 条件装配 2.自动装配正文 2. ...

  5. hive启动错误总结

    1,mysql加载的jar包未找到! ......... Caused by: org.datanucleus.exceptions.NucleusException: Attempt to invo ...

  6. SpringMVC系列(一)核心:处理请求流程

    http://blog.csdn.net/zhaolijing2012/article/details/41596803

  7. linux系统命令(调试命令)(nmtui,ip a、ss、ps、uptime、top、lsof、grep,iotop、iftop)

    本章命令 0 1 2 3 4 5 6 7 8 9 10 nmtui ip a ss ps uptime top lsof grep iotop iftop tsar nmtui 图形化管理网卡命令 依 ...

  8. Linux常用命令详解(第三章)(ping、kill、seq、du、df、free、date、tar)

    本章命令(共7个): 1 2 3 4 5 6 7 8 ping kill seq du df free date tar 1." ping " 作用:向网络主机发送ICMP(检测主 ...

  9. HDU 1754线段树

    第一个自己动手写的线段树,1Y还是有点小激动哈(虽然是模版题) 1 #include<cstdio> 2 #include<cstring> 3 #include<alg ...

  10. Codeforces Round #627 (Div. 3) F - Maximum White Subtree(深度优先搜索)

    题意: n 个点 n - 1 条边的树,问每个点所在所有子树中白黑点数目的最大差. 思路: 白点先由下至上汇集,后由上至下分并. #include <bits/stdc++.h> usin ...