jsの常用正則

2679 ワード

//     ,4 16 (  ,  ,   ,  )
let uPattern = /^[a-zA-Z0-9_-]{4,16}$/;

//      ,  6 ,    1     ,1     ,1   ,1     
let pPattern = /^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$/;

//     
let posPattern = /^\d+$/;
//     
let negPattern = /^-\d+$/;
//    
let intPattern = /^-?\d+$/;

//Email  
let ePattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

//     
let mPattern = /^1[345789]\d{9}$/;

//    (18 )  
let cP = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
//URL  
let urlP = /^((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
//    ,    ,          
let dP1 = /^\d{4}(\-)\d{1,2}\1\d{1,2}$/;
//
let dP2 = /^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/;
//     
let cPattern = /^[                                 A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9     ]{1}$/;
//      
let cnPattern = /[\u4E00-\u9FA5]/;