Could someone please explain why it doesn’t work since I used the ^\D+ which I believe should accept more than one character that isn’t a number at the beginning of the username?
The \w selects all letters and numbers, plus the underscore.
The ‘dot’, or wildcard is used to replace any one character, so it can be used as any character.
My idea was to combine both so I could finish the username with either a letter or a number without knowing which.
I’m not sure if it was a good idea or if it became a bug, but it’s working for most of the cases. I’d need someone more experienced to tell me which one is correct.
Correct. So \w. will always require two characters in your string. But \D+ is greedy and eats up as many non-digits as it can. So for the string “Jo”, \D+ eats up both of those characters, but you still have \w. wanting two characters as well. Do you see why “Jo” doesn’t pass?
\D+ is at least 1 char, so you’re forcing the string to be at least 3 chars.
Also, “non digit” may include any non digit symbols like “%” or “$”, so it isn’t an appropriate choice.