On all the lessons leading up to this challenge I understood. I took notes and have been referencing. I broke the question or problem down to:
1.) !Special characters. ([^\W])
2.) (^beginning)Any A-Z || a-z && may be repeated(+) && be anywhere but the end.
3.) Can have [0-9] but only at the end($).
4.) Minimum of 2 characters and if two{2} has to be alphabet character.
I have been trying my best to problem solve this and not guess, by going through the documentation of the methods rigorously. However, I can’t solve it and feel like I’m just guessing at this point.
The closest I got was passed all parameters but 2.
I’m looking to understand so I can solve it, not just an answer to the solution.
Thanks
let username = "JackOfAllTrades";
/* The following commented out code is just a few of the many
variations I have tried. The fails were written starting with bottom conditon up and which one I failed. */
//let userCheck = /.\w$/gi; //fail 1,3,5,6,8 from bottom up
//let userCheck = /[^\d\W$][A-Za-z-0-9]+/gi; //failed 3,5,6 from the bottom up
//let userCheck = /[\w][\D$]/gi; //failed 1,3,4,5 from bottom bottom up
//let userCheck = /^[A-Z-a-z][^0-9][0-9]$/gi; //failed 1,4,9,10,11,13 from the
//let userCheck = /[^\W]^[^\d]/gi; //fail 2,4,9,10,11,13 from the bottom up
/*let userCheck = /[^\W]^[A-Z{2}]+^[a-z{2}][^\d{2}+][\d+]$/gi; fail 2,4,9,10,11,13 from the bottom up */
let userCheck = /^[A-Za-z][^\d\W]/gi; //failed 4,5 from the bottom up
let result = userCheck.test(username);
Challenge: Restrict Possible Usernames
Link to the challenge: