Hi guys, I managed to pass all the tests except,
"Your regex should not match J "
and
"Your regex should not match A1 "
I tried multiple ways to create this code and this is the one that gave me the best results, on what I learned so far, but I guess not enough to pass.
Thank you in advance for your help.
Your code so far
let username = "JackOfAllTrades";
let userCheck = /^[A-Z]+\d*$/i;
let result = userCheck.test(username);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36.
Well then, the quantifier character {} is not yet in the curriculum, so I am actually trying to solve a challenge with something I didn’t even learn yet. Thanks for that freeCodeCamp.
you absolutely don’t need that quantifier, you can use those you already know
“at least two characters” === “one character followed by one or more characters”
you can write that second version with what was previosuly in the curriculum
there is also the version “one character followed by one character followed by zero or more characters”
Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.
as you need the two letters at the beginning for that thing, but if the username is longer it can have also une single alphabet character at the beginning
you need something more complex than this, maybe using an OR
Yeah, the challenge requires you to know a bit about the quantifier {} character or the OR | character…either one of them are not in the previous lessons…
Thanks for your time, I managed to get all of them right except two tests taking into consideration that it has a couple of important characters that can help you solve the task or at least help you understand the concept better but are not available in previous lessons, so that’s enough for me.
maybe you are right that the or is not in previous challenges, but you can have the same effect of the quantifiers with what you already know, it is just longer to write
I managed to find some videos from freeCodeCamp explaining a bit more the exercise, so I feel that I have a …ok understanding of the challenge now, using the {} and the OR | characters on it. Thanks again.
I just went through this challenge and I have to say, it was a little annoying/tricky. I ended up using the OR logic which was presented earlier in the Match a Literal String with Different Possibilities module.
If anyone knows for sure that there is a solution that does not require {} or |, I’d love to know about it.
I solved this using grouping("()") and the OR character, but grouping had definitely not been presented earlier in the curriculum. I am still unclear as to how this would be solved without grouping.
For example
/^\D[\D|\d]\d*$/ will match both “Z97” and “A9”
Does anyone have a solution that doesn’t involve grouping and the OR character?