Regular Expression for Passwords

This is just a note to myself really, below is the regular expression for a string or in my case password where you require it to have at least one letter, one number, a limited selection of special characters (optional) and a minimum of 8 characters in length:

View Code REGEX
1
^(?=.{8,})(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9@#$%^&+=\*]*$

Leave a Reply

Your email address will not be published. Required fields are marked *