Need help with this challenge

**Your code so far**

```
let sampleWord = "astronaut";
let pwRegex = /(?=\w{5,})(?=[0-9]+)/; // Change this line
let result = pwRegex.test(sampleWord);
```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36`

.

**Link to the challenge:**

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead

you need 2 consecutive digits but your regex only checks that you have 1 (+ means 1 or more) …

can you think of a way to check for 2?

hint: the solution (as I recall) is very similar to the example

```
/(?=\w{5,})(?=\D*\d\d)/g
```

i did a little thinking and i applied the code in which you have to match atleast one digit but i really cant fully understand what is going on in the second lookahead

the second look-ahead says:

Tell me if the string has any number of non-digit characters followed by two digit values

(\D* any number of non-digits)

(\d\d exactly two digits)

1 Like