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. 基于final shell的linux命令

    final shell操作教程: 1.查看API实时日志:cd ../../data/log/api tail -100f anyAPI-server.log2.关闭日志:control+c3.恢复实 ...

  2. ValueError: the environment variable is longer than 32767 characters On Windows, an environment variable string ("name=value" string) is limited to 32,767 characters

    https://github.com/python/cpython/blob/aa1b8a168d8b8dc1dfc426364b7b664501302958/Lib/test/test_os.py ...

  3. redis 主从复制 和集群

    redis集群最少三个节点 之间相互通信ping-pong 投票选举机制 主从复制 的话 最少六个节点 ,主三从三

  4. scrapy爬虫 简单入门

    1. 使用cmd+R命令进入命令行窗口,并进入你需要创建项目的目录 cd 项目地址 2. 创建项目 scrapy startproject <项目名> cd <项目名> 例如 ...

  5. Spring Cloud,Docker书籍资源、优秀博文等记录

    Spring Cloud,Docker书籍资源.优秀博文等记录 Spring Cloud,Docker书籍资源.优秀博文等记录 一.书籍 二.博文地址 三.思维导图Or图片 3.1一张图总结 Dock ...

  6. Java异常封装(自定义错误信息和描述)

    一.checked异常和unchecked异常 checked异常: unchecked异常: 二.异常封装示例 2.1.添加一个枚举LuoErrorCode.java如下: 2.2.创建一个异常类B ...

  7. JS 实现一个实时动态校验,将输入格式错误的显示为红色背景

    功能描述: 源码: 功能描述: 实时动态校验,如果输入的格式错误,将弹窗提示输入格式错误并将背景展示为红色. 源码: 前台: <hy:formfield name="cxfdl&quo ...

  8. Spring Boot:添加导出Excel表格功能

    1.添加POI依赖 2.创建EXCEL实体类 3.创建表格工具类 4.创建ExcelConstant 5.创建ExcelController 1.添加POI依赖 <dependency> ...

  9. UML实战总结——机房收费系统UML第一版部分图展

    距离机房收费系统已经过去了近2个月之久,如今的UML图才出来,从软件开发设计的逻辑上来讲这是顺序有问题的,不过,对于我们而言,而且是初次用面向对象的思想去设计和建模,就当是UML的一个实战练手的项目吧 ...

  10. OpenCV4.4.0 安装测试 Installation & Examination (Ubuntu18.04, Ubuntu 20.04)

    OpenCV4.4.0 安装测试 Installation & Examination (Ubuntu18.04, Ubuntu 20.04) 单纯简单的 OpenCV 安装配置方法,在这个地 ...