I want to use a regex to match a set of password requirements. They are:
- Needs to 8-15 characters
- One uppercase letter
- One lowercase letter
- One number
I'm using https://regexr.com/ to try to build it.
The first attempt:
/([A-Z])([a-z])([0-9])({8,15})+/g
But in the console of the web app this throws:
But in this answer, Regular expression to limit number of characters to 10 they go:
/^[a-z]{0,10}$/
So I tried to roll with this idea:
/[A-Z][a-z][0-9]{8,15}/g
And the errors clear but it is always false. Why?
Below is a sample. The alert should be true because it contains all the requirements.
function checkPass() {
var regex = /[A-Z][a-z][0-9]{8,15}/g;
var string = "G00dPassword1234"
var isItGood = regex.test(string);
alert(isItGood)
}
<button onclick="checkPass()">test</button>
Why is my test always false?