首页 > 代码库 > 常用js正则归类

常用js正则归类

//定义正则表达式//title,只能是数字字母汉字开头,不能以下划线结尾,不包含特殊字符3-20var title = /^(?!_)(?!.*?_$)[)(\sa-zA-Z0-9_\u4e00-\u9fa5\uff08\uff09]{3,20}$/;var roleName = /^[\u4e00-\u9fa5]{3,20}$/;//密码var passwordReg = /^[a-zA-Z0-9]{6,20}$/;//真实姓名var realNameReg = /^[A-Za-z0-9\u4e00-\u9fa5]+$/;//标题验证正则var titleTopicReg = /^[\sa-zA-Z0-9_\u4e00-\u9fa5\uff08\uff09#-—]{3,20}$/;//titleReg,只能是数字字母汉字开头,不能以下划线结尾,不包含特殊字符0-20var titleReg = /^(?!_)(?!.*?_$)[\sa-zA-Z0-9_\u4e00-\u9fa5]{3,20}$/;//备注regvar remarkReg = /^[a-zA-Z0-9\s\u4e00-\u9fa5]{0,20}$/;//信息来源,仅是字母和汉字空格var resource = /^[a-zA-Z\s\u4e00-\u9fa5]{3,100}$/;//分类var categoryReg = /^[a-zA-Z\s\u4e00-\u9fa5]{0,100}$/;//isbn,国际标准isbnvar isbn = /^\d{13}$/;//字母,中文,空格var author = /^[A-Za-z\s\u4e00-\u9fa5]{0,20}$/;//验证ipvar ips=/((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))/;//验证账户格式var user=/^[a-zA-Z0-9;]+$/;function isEmpty(value){    if(value =http://www.mamicode.com/="" || value =http://www.mamicode.com/= null){        return false;    }else{        return true;    }}

 

常用js正则归类