This is escaping the ^ so it is literally looking for the ^ in the username, so lose the \.
I think you just need to go through the rules again and make sure you take them all into account. I will give you a hint by saying that you are on the right track having two subpatterns separated with the OR pipe.
does ^[a-z]{2,} mean that there should be at least 2 letters at the beginning? so it doesn’t match A%B3 because the second one is not a letter even though it should match?
This is how it looks now:
/^[a-z]\d{2,}$|^[a-z][a-z]+\d*$/gi
I just removed the g from this one and it worked. Could you please explain why g made the code fail?
Correct. You could replace ^[a-z][a-z]+ with ^[a-z]{2,}.
This is caused by a “quirk” with how the tests interact with the global flag. If you want to know all the gruesome details you can find them in this thread.
You don’t need the global flag here because you aren’t searching for multiple matches in a string. Each string being tested contains only one username and you are doing the pattern matching on the entire string, not trying to find sub-patterns in the username.
Yes, technically this challenge should pass with the global flag but adding the global flag is not needed in this case, so I would argue that the challenge is teaching you not to add things that aren’t needed