Https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames

From A - Z letters and you can only use usernames from 2 characters.

not really… [A-Z]{2,} means “two or more letters”, just that

1 Like

Does “Z97” start with two or more letters?

No, it does not. It is only a letter and two numbers.

So it’s not going to match your pattern.

I will try it again.

Good morning, this code says that the first letter has to be a capital letter and the last one can be numbers and letters. How can I set the first one and the last one must be letters in the case of an username of two letters to pass the tests

/^[A-Z][A-Z0-9]{1,10}$/i

I am trying with this code with the examples in test ^[A-Za-z]+[0-9]{0,}$ and I am not getting passed. But, I use them in RegEx and I am getting them match.

What is your complete current code?

let username = "JackOfAllTrades";
let userCheck = /^[A-Za-z]+[A-Za-z]+[0-9]{0,}$/gi; // Change this line
let result = userCheck.test(username);
console.log(result);

1 Like

I tried this with RegExr and It worked with the cases, but I am trying in here and It is not getting passed. Is it a bug?

^[A-Z]([A-Z]+|[0-9]{2,})[0-9]*$/gi

Are you still using the global flag?

1 Like

I will read the article. Thanks!

Thanks for your help!
^[A-Z]([A-Z]+|[0-9]{2,})[0-9]*$/i

Congratulations! Happy coding.

1 Like