常用的正则校验,react
可直接导入使用
class AppStore {
@observable phoneReg = /^1[3456789]\d{9}$/;//手机号码
@observable carNumReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-HJ-NP-Z]{1}[A-HJ-NP-Z]{1}[A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;//车牌号码
@observable numberReg = /^\d+$/; // 非负整数
@observable mailReg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;//邮箱
@observable licenseReg = /(^(?:(?![IOZSV])[\dA-Z]){2}\d{6}(?:(?![IOZSV])[\dA-Z]){10}$)|(^\d{15}$)/;//营业执照
@observable companyNameReg = /^([\u4e00-\u9fa5+]{2,20}$)/;//企业名称
@observable adressReg = /^[A-Za-z\d_\d.\-\u4e00-\u9fa5]{6,}/;//地址
@observable legalPersonIssAuthorityReg = /^[A-Za-z\d_\d.\-\u4e00-\u9fa5]{4,}/;//签发机关名称
@observable nameReg = /^([\u4e00-\u9fa5+\·?\u4e00-\u9fa5+]{2,20}$)/;//名字
@observable identReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;//身份证
@observable chineseReg = /^[\u4e00-\u9fa5]+$/ //汉字
@observable vinReg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{17}$/ //签约车辆识别代码
@observable engineNoReg = /^[0-9A-Za-z]+$/ // 发动机号
@observable numFloatReg = /^\d+(\.\d+)?$/ //非负数字 允许小数
@observable specialCharactersReg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]/im //特殊字符检验
}
const appStore = new AppStore();
export default appStore;