邮箱

验证邮箱。

语法

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

参数

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

返回值

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

源码

  1. const emailReg = (value) => {
  2. 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,}))$/;
  3. return reg.test(value);
  4. };

例子

  1. import { emailReg } from 'warbler-js';
  2. const result1 = emailReg('1741847465@qq.com')
  3. const result2 = emailReg('http://warbler.duwanyu.com/')
  4. console.log(result1) // true
  5. console.log(result2) // false