Help me understand why \w* is necessary

Hey welcome to forum :slight_smile:

You want your regex to match passwords that have two consecutive digits somewhere in the string.

If the \w* is omitted then the regex requires that the two consecutive digits immediately follow the non-digit at the start of the string. By putting the \w*, your regex allows for zero or more characters in between the non-digit at the start of the string and the two consecutive digits.

This answer may also be useful to you: Regular Expressions: Positive and Negative Lookahead Questions

2 Likes