Tell us what’s happening:
Describe your issue in detail here.
Hi, I have a fast theory question here. In the correct answer to this question, we are supposed to specify in a regional expression that passwords have to be greater than 5 characters long, whatever those characters are.
I had chosen to use \w{5,} to ‘at least’ make sure in the lookahead that the password would hit at least 5 characters. I’m fine with all other aspects of the code, but I do not understand why we are working with {6} here.
As I recall from the ‘Specify Exact Number of Matches’ lesson, using the curly braces indicates that we are looking for that exact match - in this case, exactly 6 elements/characters from the \w category.
I’m uncertain why the \w{5,} wouldn’t work, as that would hit at least 5 characters from the \w shorthand, and it wouldn’t require a 6 character only password.
Thank you all for the help!
Your code so far
let sampleWord = "astronaut";
let pwRegex = /(?=\w{5,})(?=\w*\d{2})/;
// Change this line
let result = pwRegex.test(sampleWord);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Challenge: Regular Expressions - Positive and Negative Lookahead
Link to the challenge: