Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: What's a good maxlength for an alphanumeric username?

  1. #11
    txtsd's Avatar
    Joined
    Dec 2012
    Posts
    642
    Userbars
    7
    Thanks
    538
    Thanked
    327/146
    DL/UL
    60/2
    Mentioned
    91 times
    Time Online
    31d 8h 56m
    Avg. Time Online
    10m
    Quote Originally Posted by Criminal View Post
    I like periods/hyphens more than underscores. Idk why.
    BECAUSE PERIODS!



    Quote Originally Posted by Zeus View Post
    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.

  2. #12
    Zeus's Avatar
    Joined
    Jan 2012
    Posts
    903
    Userbars
    8
    Thanks
    797
    Thanked
    557/243
    DL/UL
    338/0
    Mentioned
    233 times
    Time Online
    86d 10h 37m
    Avg. Time Online
    29m
    Quote Originally Posted by txtsd View Post
    BECAUSE PERIODS!





    4 hours later, still waiting for OP to deliver.


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

  3. The Following User Says Thank You to Zeus For This Useful Post:

    txtsd (09-08-2015)

  4. #13
    txtsd's Avatar
    Joined
    Dec 2012
    Posts
    642
    Userbars
    7
    Thanks
    538
    Thanked
    327/146
    DL/UL
    60/2
    Mentioned
    91 times
    Time Online
    31d 8h 56m
    Avg. Time Online
    10m
    @(you need an account to see links) @(you need an account to see links) 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.

  5. #14
    Zeus's Avatar
    Joined
    Jan 2012
    Posts
    903
    Userbars
    8
    Thanks
    797
    Thanked
    557/243
    DL/UL
    338/0
    Mentioned
    233 times
    Time Online
    86d 10h 37m
    Avg. Time Online
    29m
    Quote Originally Posted by txtsd View Post
    @(you need an account to see links) @(you need an account to see links) 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.

  6. The Following 2 Users Say Thank You to Zeus For This Useful Post:

    Roslyn (09-09-2015),txtsd (09-09-2015)

  7. #15
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    Quote Originally Posted by Zachafer View Post
    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):
    PHP Code:
    $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.
    PHP Code:
    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-]

    PHP Code:
    $rgx '/^[a-z](?:[a-zA-Z0-9]|(-)(?!\1)){2,23}$/i'
    Last edited by Zachafer; 09-08-2015 at 11:20 PM.

  8. The Following User Says Thank You to Zachafer For This Useful Post:

    Zeus (09-08-2015)

  9. #16


    Roslyn's Avatar
    Joined
    Jan 2014
    Posts
    423
    Userbars
    9
    Thanks
    734
    Thanked
    923/336
    DL/UL
    3/0
    Mentioned
    248 times
    Time Online
    58d 6h 40m
    Avg. Time Online
    22m
    Quote Originally Posted by Zeus View Post
    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. (:


    I love Jess

  10. #17
    txtsd's Avatar
    Joined
    Dec 2012
    Posts
    642
    Userbars
    7
    Thanks
    538
    Thanked
    327/146
    DL/UL
    60/2
    Mentioned
    91 times
    Time Online
    31d 8h 56m
    Avg. Time Online
    10m
    Quote Originally Posted by Zachafer View Post
    PHP Code:
    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-]

    PHP Code:
    $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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •