1、驗(yàn)證時(shí)間格式(xxx-xx-xx xx-xx-xx 或 xxx-x-xx xx-xx-xx)
/^(20|19)[0-9][0-9]-(0?[1-9]|1[0-2])-(0[1-9]|[1-3][0-1])\s(0[0-9]|1[1-2]|2[0-3]):(0[0-9]|[1-5][0-9]):(0[0-9]|[1-5][0-9])$/
范圍:
1900-01-01 00:00:00
2099-12-31 23:59:59
2、必須是數(shù)字或字母、開(kāi)頭,長(zhǎng)度不限
/^[a-zA-Z\d]+/
例如:
a1000 ,a漢字 ,0漢字
3、郵箱前綴
/^[a-zA-Z\d]+([a-zA-Z\d-_.])*/
例如:
zhangsan,zhangsan.info,zhang-san,zhagn--san ,zhang_san
4、匹配域名后綴?
/^([.][a-zA-Z]+){1,7}$/;
例如:
.com.cn, .com, .cn, .me, .net, .net.cn,.top
ps:目前已知域名最長(zhǎng)的后綴為?.fashion 最短的為.cn,未發(fā)現(xiàn)后綴中含有數(shù)字或含有下劃線或中橫線的。
5、匹配郵箱?
/^[a-zA-Z\d]+([a-zA-Z\d-_.])*@[a-zA-Z\d]+[a-zA-Z-_\d]*([.][a-zA-Z]{2,7}){1,2}$/
例如:
123@qq.com,abce@q-1.com.cn , a1d3@163.com,abce.dd@wo-china.com.cn,abce.dd@wo_china.com.cn
6、匹配大于0的正整數(shù)
/^[1-9]\d*$/
ps:限制最大幾位可以將*替換為{n-1}
7、匹配浮點(diǎn)型數(shù)據(jù)
/^([1-9][\d]*|0)([.]\d{1,2})?$/
例如: 0,0.3,112.93
8、匹配漢字(簡(jiǎn)體、繁體)
^[\u4E00-\u9FA5]+$? ? ?//此處注意大小寫(xiě) 至少一個(gè)漢字
9、匹配空格
全局匹配:/\s/g
左所有空格 /^\s+/
右側(cè)所有空格?/\s+$/
左右兩側(cè)所有空格 /^\s+|\s+$/g
ps:\s匹配空格外還匹配tab制表符,如僅匹配空格請(qǐng)使用 / /g
有問(wèn)題歡迎大家糾錯(cuò)哈~