帮助,我需要一个regexp验证,用一些特殊字符(@#$%&)来检查字母数字(AZ或az和0-9),这是可选的,但长度必须是8到15个字符
例如,
training = false
training1 = true
@training1 = true
@training = false
tr@ining1 = true (Position doesn't matter)
我有这个,但它只验证长度为8到15个字符的字母数字
(?=.*[A-Za-z])(?=.*[0-9]){8,15}
如何包含特定字符的可选检查?
答案 0 :(得分:0)
/^(?![a-z]+$)(?![a-z@#$%&]+$)(?!\d+$)(?![\d@#$%&]+$)[a-z\d@#$%&]{8,15}$/i
匹配结果:
training = false
training1 = true
@training1 = true
@training = false
tr@ining1 = true
12345678 = false
12345678a = true
@12345678 = false