regex - Regular Expression for Password strength with one special characters except Underscore -
i have following regular expression:
^.*(?=^.{8,}$)(?=.*\d)(?=.*[!@#$%^&*-])(?=.*[a-z])(?=.*[a-z]).*$ i using validate
@ least 1 letter
least 1 capital letter
least 1 number
least 1 special characters
least 8 characters
but along need restrict underscore (_). if enter password pa$sw0rd, validating correctly, true. if enter pa$_sw0rd validating correctly, wrong.
the thing regex passing when rules satisfied. want rule restrict underscore along above.
any appreciable.
i think can use negated character class [^_]* add restriction (also, remove initial .*, redundant, , first look-ahead @ beginning of pattern, no need duplicate ^, , totally redundant since total length limit can checked @ end):
^(?=.*\d)(?=.*[!@#$%^&*-])(?=.*[a-z])(?=.*[a-z])[^_]{8,}$ see demo
Comments
Post a Comment