An expression like:
[a-zA-Z]*[0-9\+\*][a-zA-Z0-9\+\*]*
should work fine (obviously, insert any additional special characters you want to allow or use the ^ operator to match anything other than letters / numbers); no need to use complex images. This approach makes sense if you only want to allow a specific subset of special characters that you know are βsafeβ and prohibit everyone else.
If you want to include all special characters except certain ones that you know are βunsafe,β then it makes sense to use something like:
\w[^\\]*[^a-zA-Z\\][^\\]*
In this case, you explicitly prohibit the backslash in your password and allow any combination with at least one non-alphabetic character.
The above expression will match any string containing letters and at least one number or +, *. Regarding the requirement of βlength 8β, there really is no reason to verify that using regular expression.
source share