I need help creating the regex for a password.
The password can contain letters, numbers, underscores ( _ ), dollar signs ( $ ) and hyphens ( – ), must be at least 3 characters long and at most 30 characters long.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Letters, numbers, underscores, dollar signs and hyphens are covered by this:
Limiting it to 3 to 30 is covered by this:
In the end, we can reduce it a bit by adding the case-insensitive modifier:
Adding the
^and$force it to match from start to finish, meaning we won’t be matching a subset of the tested string. Either the entire submitted string passes, or fails.You can try it out against a few password by visiting http://regexr.com?30ru6