Skip to content
大纲

邮箱

验证邮箱。

语法

js
import { emailReg } from 'warbler-js';
const result = emailReg(value);

参数

  • value (String) : 待验证字符串。

返回值

Boolean : 是否通过验证,true 通过验证, false 没有通过验证。

源码

js
const emailReg = (value) => {
  const reg =
    /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return reg.test(value);
};

例子

js
import { emailReg } from 'warbler-js';
const result1 = emailReg('1741847465@qq.com');
const result2 = emailReg('http://www.warblerfe.top/');

console.log(result1); // true
console.log(result2); // false

添加版本

1.2.0

Released under the MIT License.