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:
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.