PDA

View Full Version : What's a good maxlength for an alphanumeric username?



txtsd
09-07-2015, 06:10 AM
Neopets' maxlength is 20, and they allow a-zA-Z0-9_
But now the good usernames are mostly gone.

What do you think is a good maxlength and charset?
AND
Do you think usernames should be case-sensitive? As in "derp", "Derp", "derP", "DERP", should all count as different usernames, or is there a disadvantage to doing this?

Zeus
09-07-2015, 07:04 AM
Neopets' maxlength is 20, and they allow a-zA-Z0-9_
But now the good usernames are mostly gone.

What do you think is a good maxlength and charset?
AND
Do you think usernames should be case-sensitive? As in "derp", "Derp", "derP", "DERP", should all count as different usernames, or is there a disadvantage to doing this?



I agree with how Neopets is setup.
I'd hate if I got a badass neopets name like "Pizza" and then the following imitators appeared -
"pIzza"
"PiZzA"
etc

DrSloth
09-07-2015, 08:41 AM
specially with a capital i looking like and l depending the font you you.

Zachafer
09-07-2015, 10:36 AM
What's the application for? What are the usernames for?

Case insensitivity is a MUST! Pizza = pizza = PIZZa = pizZa
All usernames should be lowercased in the database imo.
I woud allow [a-z0-9_] characters. Maybe a hyphen (-) character

txtsd
09-07-2015, 07:15 PM
I agree with how Neopets is setup.
I'd hate if I got a badass neopets name like "Pizza" and then the following imitators appeared -
"pIzza"
"PiZzA"
etc

specially with a capital i looking like and l depending the font you you.

What's the application for? What are the usernames for?

Case insensitivity is a MUST! Pizza = pizza = PIZZa = pizZa
All usernames should be lowercased in the database imo.
I woud allow [a-z0-9_] characters. Maybe a hyphen (-) character

Just a petsite project that I'm building, while I learn Go and relearn SQL, that most likely will go public within the next year.

Okay, so case-insensitive. But storing as lowercase might not be the best way to go about things. Lowercasing it for any related logic makes sense though. If I stored it as lowercase, your username would be zachafer, not Zachafer. And I'm sure people can be super anal about that, especially since I get ticked off to no end when my username is unnecessarily capitalized (fucking twitch chat).

Zachafer
09-07-2015, 09:31 PM
Just a petsite project that I'm building, while I learn Go and relearn SQL, that most likely will go public within the next year.

Okay, so case-insensitive. But storing as lowercase might not be the best way to go about things. Lowercasing it for any related logic makes sense though. If I stored it as lowercase, your username would be zachafer, not Zachafer. And I'm sure people can be super anal about that, especially since I get ticked off to no end when my username is unnecessarily capitalized (fucking twitch chat).
Then go with a site-wide capitalization standard. The first letter is capatilized? Unless you want usernames like "alIlIlIlIlIlIllIIlllIIl"

txtsd
09-07-2015, 11:00 PM
Then go with a site-wide capitalization standard. The first letter is capatilized? Unless you want usernames like "alIlIlIlIlIlIllIIlllIIl"

A site-wide capitalization standard is exactly what I do not want :(
I'm leaning towards a maxlength of 24 and possibly
/^[a-zA-Z][a-zA-Z0-9]*$/

Disallowing underscores will prevent the universally ugly xx_herpderp_xx style names.
Everything else is mostly alright, I think.

Zachafer
09-07-2015, 11:12 PM
A site-wide capitalization standard is exactly what I do not want :(
I'm leaning towards a maxlength of 24 and possibly
/^[a-zA-Z][a-zA-Z0-9]*$/

Disallowing underscores will prevent the universally ugly xx_herpderp_xx style names.
Everything else is mostly alright, I think.Personally, I'm a fan of allowing underscores (or spaces) in the username.

Also, you could use something like this for your username regex (specifies length 3-24):

$rgx = '/^([a-z][a-z0-9]{2,23})$/i';

Roslyn
09-08-2015, 05:57 AM
I like periods/hyphens more than underscores. Idk why.

Zeus
09-08-2015, 06:05 AM
A site-wide capitalization standard is exactly what I do not want :(
I'm leaning towards a maxlength of 24 and possibly
/^[a-zA-Z][a-zA-Z0-9]*$/

Disallowing underscores will prevent the universally ugly xx_herpderp_xx style names.
Everything else is mostly alright, I think.

I'm going to send you a PM as I have some ideas, but I do believe you should allow hyphens. -

txtsd
09-08-2015, 10:49 AM
I like periods/hyphens more than underscores. Idk why.
BECAUSE PERIODS!

[Only registered and activated users can see links]


I'm going to send you a PM as I have some ideas, but I do believe you should allow hyphens. -

4 hours later, still waiting for OP to deliver.

Zeus
09-08-2015, 11:49 AM
BECAUSE PERIODS!

[Only registered and activated users can see links]



4 hours later, still waiting for OP to deliver.



Sorry man, still working on previous project. Will be mailing you now. :)

txtsd
09-08-2015, 10:38 PM
Criminal Zeus Are you guys advocating multiple hyphens or a single hyphen?
Because people might make silly usernames like X------D and B-------D
I-H-I looks like a cool fighter drone though, so idk.

Zeus
09-08-2015, 11:03 PM
Criminal Zeus Are you guys advocating multiple hyphens or a single hyphen?
Because people might make silly usernames like X------D and B-------D
I-H-I looks like a cool fighter drone though, so idk.

My original proposal was multiple hyphens that can't be in sequential order. But that seems like a bit much so possibly just a single hyphen. :)

Zachafer
09-08-2015, 11:14 PM
Personally, I'm a fan of allowing underscores (or spaces) in the username.

Also, you could use something like this for your username regex (specifies length 3-24):

$rgx = '/^([a-z][a-z0-9]{2,23})$/i';
My original proposal was multiple hyphens that can't be in sequential order. But that seems like a bit much so possibly just a single hyphen. :)

function validateUsername($test)
{
$rgx = '/^([a-z][a-z0-9-]{2,23})$/i';
return preg_match($rgx, $test) && strpos($test, '--') === false;
}Or the all in one regex (wow)

Case insensitive
Username length 3-24
Username starts with a-z
Username can contain hyphens but cannot contain repeating hyphens
Username allows character [a-z0-9-]


$rgx = '/^[a-z](?:[a-zA-Z0-9]|(-)(?!\1)){2,23}$/i';

Roslyn
09-09-2015, 06:04 AM
My original proposal was multiple hyphens that can't be in sequential order. But that seems like a bit much so possibly just a single hyphen. :)

This sounds right. (:

txtsd
09-09-2015, 06:17 AM
function validateUsername($test)
{
$rgx = '/^([a-z][a-z0-9-]{2,23})$/i';
return preg_match($rgx, $test) && strpos($test, '--') === false;
}Or the all in one regex (wow)

Case insensitive
Username length 3-24
Username starts with a-z
Username can contain hyphens but cannot contain repeating hyphens
Username allows character [a-z0-9-]


$rgx = '/^[a-z](?:[a-zA-Z0-9]|(-)(?!\1)){2,23}$/i';

Holy wowza! I've never used a negative lookahead assertion before.
I don't use php, but thanks. The regex will do just fine.

And thanks everyone for your inputs!