Regular expressions are cryptic and hard to understand and build one from scratch. But don't panic with those cryptic symbols, the dev community can help. Here i am writing 3 password regular expressions to use it at your next JavaScript front end app or your next nodeJs back end application.
// PASSWORD REGEX FOR YOUR NEXT JAVASCRIPT APP
// regex for a basic password must be
// more than 8 chars
const PASSWORD_REGEX_1= ^[A-Za-z0-9]\w{8,}$/;
// more secure regex password must be
// more than 8 chars
// at least one number
const PASSWORD_REGEX_2 = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$/;
// more secure regex password must be :
// more than 8 chars
// at least one number
// at least one special character
const PASSWORD_REGEX_3= /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{8,}$/;
You can combine all 3 regular expressions to show proper warning messages.
Great web sites to check your regular expressions :