/** * @Author: xiaozuo28 * @Date: 2022年5月13日08:05:20 * @LastEditors: xiaozuo28 * @LastEditTime: 2022年7月17日08:42:42 * @Description: 正则表达式处理 **/ export default { /** * @Description 校验字符串是否为空 * @Date 2022年5月19日10:45:51 * @Param {String} sting 待校验字符串 * @Return {Boolean} true:为空,false:不为空 **/ isStringEmpty(string = ''){ if(string === undefined || string === null){ return true; } if(string.trim().length === 0){ return true; } else { return false; } }, /** * @Description 校验字符串是否为身份证号 * @Date 2022年5月19日10:56:51 * @Param {String} sting 待校验字符串 * @Return {Boolean} true:是,false:不是 **/ isIDCard(string = ''){ let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; return reg.test(string); }, /** * @Description 校验字符串是否为手机号码 * @Date 2022年5月19日11:17:23 * @Param {String} sting 待校验字符串 * @Return {Boolean} true:是,false:不是 **/ isPhone(string = ''){ let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; return reg.test(string); }, /** * @Description 校验字符串是否为Email * @Date 2022年5月19日11:17:23 * @Param {String} sting 待校验字符串 * @Return {Boolean} true:是,false:不是 **/ isEmail(string = ''){ let reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; return reg.test(string); } }