Skip to content
大纲

微信号

验证 微信 号。620 位,要求以 字母 开头,允许 字母数字减号下划线

语法

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

参数

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

返回值

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

源码

js
const wechatReg = (value) => {
  const reg = /^[a-zA-Z][-_a-zA-Z0-9]{5,19}$/;
  return reg.test(value);
};

例子

js
import { wechatReg } from 'warbler-js';
const result1 = wechatReg('yiweiliuying0309');
const result2 = wechatReg('warbler_js');

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

添加版本

1.2.0

Released under the MIT License.