Lets start off with the (?=\w{5,}) part. You need to have more than 5 chars which means that this will pass if we have exactly 5 characters. It will pass for more as well but we shouldn’t be passing for 5 chars.
When it comes to (?=\d\d), this is probably the way I did it my first time as well, and I’d suggest you try to think here what the whole password needs to look like in order to be parsed correctly instead of just requiring 2 numbers.
The code snippet you provided has an error in the pwRegex regular expression. The purpose of this regular expression is to validate whether the sampleWord string meets certain conditions, but the current regular expression is not doing what is intended. Here are the problems:
(?=\w{5,}): This part of the regular expression is used to check if there are at least 5 alphanumeric characters in the string. However, it doesn't actually check if all the characters in the string are alphanumeric, but only checks if there are at least 5 alphanumeric characters somewhere in the string. This means that a string like "astronaut1" would pass validation, but a string like "astr1" would also pass validation.
(?=\d\d): This part of the regular expression is used to check if there are at least two digits in the string. However, similar to the first part, it only checks if there are at least two digits somewhere in the string, rather than checking if all characters are digits.