正向先行断言


(?=.?[A-Z]+)(?=.?[a-z])(?=.[!@#$%^&?()])

判断包含至少一个大写字母,一个小写,一个特殊

首先(?=.*?[A-Z]+)

这里前面是空白符,因此会匹配出所有满足(?=.*?[A-Z]+)的空白符

(?=.?[A-Z]+)(?=.?[a-z])

这里是用已经满足第一个条件的空白符继续匹配满足(?=.*?[a-z])的空白符

(?=.?[A-Z]+)(?=.?[a-z])(?=.[!@#$%^&?()])

同理

^.(?=.{6,16})(?=.\d)(?=.[A-Z]{2,})(?=.[a-z]{2,})(?=.[!@#$%^&?()]).*$

反向正行断言

(?!)

正向反行断言 : 右到左

(?<=)

反向反行断言

(?<!)


Author: Moule Lin
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Moule Lin !
  TOC