I want to create a regular expression for password which must have
- a minimum of 7 characters
- with at least 1 number and 1 alphabet within that first 7 characters.
I want to create a regular expression for password which must have
Since the characters after the first 7 do not require checking, you can run a regex just on the first 7:
/^(?=.*[0-9a-zA-Z]).{7}$/.test(password.substring(0,8))