正则练习

正则图:https://jex.im/regulex/#!flags=&re=%5E(a%7Cb)*%3F%24

非全数字

 /$(?<=^\d+)/g.test('123')

/(?=\d+$)^/.test('123')

密码长度 6-12 位,由数字、小写字符和大写字母组成,但必须至少包括 2 种字符

/((?=.*[a-z])(?=.*[A-Z])|(?=.*[a-z])(?=.*[0-9])|(?=.*[0-9])(?=.*[A-Z]))^[a-zA-Z0-9]{6,12}$/g.test('123456az')

用(?.*[a-z])匹配 有任意多个字符后面跟a-z即表示必须包含a-z

另一种解法 至少数字、小写、大写任意包含2种;也就是不能为其中一种  用(?!p)

/(?!^[0-9]{6,12}$)(?!^[a-z]{6,12}$)(?!^[A-Z]{6,12}$)^[0-9A-Za-z]{6,12}$.test('123456az')

(?!p)一般有不能全为  (?!^[0-9]+$)   或者不能包含(?!.*[0-9]+)

 

 

/(?!^)((?=(\d{3})+(?<!\.\d+)$)|(?=(\d{3})+\.\d+$))/g
/\d{1,3}((?=(\d{3})+\.\d+$)|(?=(\d{3})+(?<!\.\d+)$))/g
/(?<![\\/]node_modules[\\/].*)\.css$/.test('./node_modules/fsdfsd/index.css')

posted @ 2019-09-18 07:25  little_ab  阅读(209)  评论(0编辑  收藏  举报