Regular Expressions - Positive and Negative Lookahead

Tell us what’s happening:
The language strikes me as ambiguous.

Your code so far
/(?=.{6,})(?=\d\d)/;

This checks that the string is “greater than 5 characters long” and has “two consecutive digits.” no?

Seems like all answers require for the second lookahead that it references any number of non-digit numbers before the two digits, but why is that necessary?

let sampleWord = "astronaut";
let pwRegex = /(?=.{6,})(?=\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/113.0.0.0 Safari/537.36

Challenge: Regular Expressions - Positive and Negative Lookahead

Link to the challenge:

hello and welcome to fcc forum :slight_smile:

  • yes but there could be more digits than just two, main clause here is to have “at least two digits”
  • it seems like it needs “\D+”, for hints look into “example code” for this step

adjust this change and it should be alright, happy learning :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.