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. 接口新建学习---HTTP请求默认值

    一.HTTP请求默认值 1.使用场景: 每次访问论坛的地址(服务器名称或IP)是不变的,端口也是不变的,协议也是不变的(http协议),测试的时候需要每个请求都要写一遍,在我们的HTTP请求取样器数量 ...

  2. Unix Socket 代理服务 unix域套接字

    基于Unix Socket的可靠Node.js HTTP代理实现(支持WebSocket协议) - royalrover - 博客园 https://www.cnblogs.com/accordion ...

  3. 反弹SHELL介绍及原理

    如果我们需要到服务器上执行 Shell 命令,但是因为防火墙等原因,无法由客户端主动发起连接的情况,就可以使用反弹 Shell 来满足登陆和操作的需求. 什么是反弹Shell 正常情况下,我们登陆服务 ...

  4. Java方式导出EXCEL表格

    最近几天做公司项目,应客户需求需要将表单的数据下载本地存成.xls文件.之前做毕设的时候,就有类似这方面的功能需 求,但是当时也没有做就搁浅了下来,这次补上. 一.业务开发描述 二.前台jsp页面及j ...

  5. cachedThreadPool缓存线程池

    package com.loan.modules.common.util; import java.util.concurrent.BlockingQueue; import java.util.co ...

  6. sql,关键字使用

    select instr('dds万','万',1) from dual --判断万关键字是否存在 select to_single_byte('9') from dual --全角数字转为半角数字 ...

  7. 5. Linux文件目录管理和打包压缩与搜索命令

    1.touch:用于创建空白文件或设置文件的时间 举例:使用ls 命令查看一个文件的修改时间,然后修改这个文件,最后再通过touch命令把修改后的文件时间设置成修改之前的时间(很多黑客就是这样做的): ...

  8. E - E(最短路解决源点到多点,多点到源点的和(有向图))

    问从1号点到各个点的距离+各个点到1号点之间的距离和的最小值 详解键连接https://www.cnblogs.com/csx-zzh/p/13411588.html In the age of te ...

  9. Codeforces Round #613 (Div. 2) C. Fadi and LCM(LCM & GCD)

    题意: LCM(a, b) = X,求 max(a, b) 的最小值. 思路: a, b 只可能存在于 X 的因子中,枚举即可. #include <bits/stdc++.h> usin ...

  10. HDU4622 Reincarnation【SAM】

    HDU4622 Reincarnation 给出一个串,每次询问其一个子串有多少不同的子串 按每个后缀建立\(SAM\)不断往后加字符,然后记录答案,查询的时候直接用即可 //#pragma GCC ...