let sampleWord = "astronaut";
let pwRegex = /(?=\w{5,})(?=\D*\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:69.0) Gecko/20100101 Firefox/69.0.
Link to the challenge:
this is what i dont understand here. i get the instructions what to do for the code and this is where they put a wrench of the given solution on the website with \D*. you are asked to write a code with greater than 5 characters and have two digits. why does this need to be called \D* where the instruction specifically asks for digits and characters and not for non characters.
In a real life scenario I would use (?=[a-z])\w+([0-9]{2}) which is totally valid but it doesn’t use 2 look a heads.
I’m not sure what they are trying to accomplish.
I don’t have a problem using the metacharacter but like I said their regex isn’t even valid, and doing 2 look aheads…I can’t even think of a use case for that.
You don’t even have look aheads in python anymore. You just make groups and you can use either group by calling it like an array object.