Positive Negative Lookahead

I don’t know why I ma not passing please help

Your code so far


let sampleWord = "astronaut";
let pwRegex = /(?=^\D)(?=\D*\d\d)/; // Change this line
let result = pwRegex.test(sampleWord);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.

Challenge: Positive and Negative Lookahead

Link to the challenge:

Your regular expression is this:

Positive Lookahead

(?=^\D)

Assert that the Regex below matches

^ asserts position at start of the string

\D matches any character that’s not a digit (equal to [^0-9])

Positive Lookahead

(?=\D*\d\d)

Assert that the Regex below matches

\D*

matches any character that’s not a digit (equal to [^0-9])

  • Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)

\d matches a digit (equal to [0-9])

\d matches a digit (equal to [0-9])

You don’t pass this term:

"astr1on11aut"

I think it’s because you didn’t defined a pattern for the alphabets at the end.