Tell us what’s happening:
Guys, Im stucked in this Regex lesson, I can’t figure it out why isn’t passing the test. I am doing the same test at Mozilla website and it’s working.
The solution hint didn’t help me at all, so can someone please explain this?
Thanks
My code so far
let username = "JackOfAllTrades";
let userCheck = /^[a-z]{2,}([a-z0-9]*)/ig; // Change this line
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/80.0.3987.149 Safari/537.36.
Let me just show you a example that might help you on your way to understanding this. Ok lets say we have a form that you must check if you are only entering text and nothing else.
js:
`
var name = document.getElementById(‘name’);
var RegEx = /^[a-z]{10}$/;
if (!RegEx.test(name.value)) {
document.getElementById('error').innerHTML = 'Please only text '
return false;
Thank you all guys, I read the explanation more carefully in FCC Guide and I get it.
Code Explanation
1. `^` - start of input
2. `[a-z]` - first character is a letter
3. `[0-9]{2,0}` - ends with two or more numbers
4. `|` - or
5. `[a-z]+` - has one or more letters next
6. `\d*` - and ends with zero or more numbers
7. `$` - end of input
8. `i` - ignore case of input