Question
I would like to be able to use a single regex (if possible) to require that a string fits [A-Za-z0-9_] but doesn't allow:
- Strings containing just numbers or/and symbols.
- Strings starting or ending with symbols
- Multiple symbols next to eachother
Valid
test_0123t0e1s2t30123_testte0_s1t23t_t
Invalid
t__t____01230123_0123_test_test123test_test123_
Reasons for the Rules
The purpose of this is to filter usernames for a website I'm working on. I've arrived at the rules for specific reasons.
Usernames with only numbers and/or symbols could cause problems with routing and database lookups. The route for
/users/#{id}allowsidto be either the user's id or user's name. So names and ids shouldn't be able to collide._testlooks wierd and I don't believe it's valid subdomain i.e._test.example.comI don't like the look of
t__tas a subdomain. i.e.t__t.example.com