Hello, I am trying to do this exercise and I am stuck, actually I do not understand why it does not accept one condition(this is the only one missing to pass this task) :
Your regex should match "bana12"
when this is
Passed
Your regex should match "abc123"
How come it can pass “abc123” and not “bana12”. What should I change in the code to have this fixed? I spent 40min on this and I cannot notice that.
Thank you in advance
My code looks like that:
Your code so far
let sampleWord = "astronaut";
let pwRegex = /(?=\w{5,})(?=\D?\w\d{2,})/; // Change this line
let result = pwRegex.test(sampleWord);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0.
both lookaheads start looking from same position.
so you have that the second lookahead wants one or zero non number character ([^0-9]), than one word character ([a-zA-Z0-9_]) and then at least two numbers
I don’t know why one pass and he other not, but your code doesn’t match requirements
Thank you for the answer, but I do not understand why the second lookahead does not find substring “ana12”, if it takes 5 characters from “abc123” why it cannot do it in this case aswell.