I was able to pass the Positive and Negative Lookahead section, but I’m still having issues understanding exactly how it works.
It’s my understanding that lookaheads will return true or false based on whether the string we are testing it against matches the patterns inside the Regex.
In my own JS environment I tested the following Regex:
/(?=\w{3,6})(?=\d)/
My understanding would be it would return True, if: the string is between 3 and 6 alphanumeric characters in length and it begins with a number.
I tested the regex against the following values and added their results (True or False):
2abc = true
abc1 = false
abc12 = false
abc123 = true
2abcdefghi = true
I’m wondering why “abc123” returned True, as it does not start with a number (?=\d).
And why 2abcdefghi returned True, when it is longer than 6 characters.
you need to write inside the pattern that it needs to start at the beginning of the string and end at the end
you have met it already in the curriculum, do you remember what’s used for that? if you don’t try to look at the titles of the challenges in that section, maybe one will remind you of something or you find which challenge you need to review
or try to use google