Username RegEx

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmurrayhead
    Senior Member
    • Sep 2006
    • 1642

    Username RegEx

    Hello,

    I want to require users enter their username in this format:

    firstname.lastname00

    Where firstname would be A-Za-z, the period is mandatory, lastname would also be A-Za-z, and the 00 is optional 0-9. For example, a user could have the following:

    john.doe
    john.doe1
    john.doe12

    Would anybody be able to assist me with this?

    Cheers!
    No...No...Meester vBulletin, he no work right.
  • Jose Amaral Rego
    Senior Member
    • Feb 2005
    • 11058
    • 1.1.x

    #2
    I do not know how you can make it mandatory to follow that string you are suggesting, you might need to ask over at vBulletin.org or place new member on moderation and make sure they follow registation page. You might need to manually edit each member that does not have that format.

    You can edit phrase 'to_post_must_first_register' and add requirements or say you be not accepted......


    vBulletin Options > vBulletin Options > User Registration Options > Username Regular Expression:
    ^[A-Za-z0-9.]+$

    You may require the username to match a PCRE-type regular expression.

    (Do not start or end the expression with an escape character)

    Examples:

    ^[A-Z]+$ - Characters from A-Z only
    ^[A-Z ]+$ - Characters from A-Z including space
    ^[A-Z0-9 ]+$ - Alphanumeric characters including space
    ^[\x20-\x7E]+$ - ASCII characters from 32-127

    See PHP.net for more information on regular expressions.

    Comment

    • jmurrayhead
      Senior Member
      • Sep 2006
      • 1642

      #3
      it should be possible, I don't know if VB interprets it or not. I develop sites using (dare I say) ASP.Net and I'm able to do some crazy things with Regex, (which I usually Google for the expressions I need). Anyway, I'll keep poking around and see what I can come up with.

      Thanks anyway
      No...No...Meester vBulletin, he no work right.

      Comment

      • Jose Amaral Rego
        Senior Member
        • Feb 2005
        • 11058
        • 1.1.x

        #4


        Look for 'Pattern Matches' or file name extensions, but I have test one version and it kept on saying Username exist, even thou I only have three(3) members on test board. You still have to edit that phrase 'to_post_must_first_register' and add some note to it or nobody will be able to register.

        Comment

        • jmurrayhead
          Senior Member
          • Sep 2006
          • 1642

          #5
          Cheers, I'll see what I can work out with the information provided.

          Thanks again
          No...No...Meester vBulletin, he no work right.

          Comment

          • Wayne Luke
            vBulletin Technical Support Lead
            • Aug 2000
            • 74132

            #6
            You couldn't restrict it to known names. I mean a regex for john.smith01 would also match dog.food47. But you can use a regex for check for the format you want.

            www.regexlib.com might have one you can use.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API

            Comment

            • pleroy
              New Member
              • Jun 2007
              • 9

              #7
              Would it be possible to have a PCRE for this: Firstname Lastname, i.e., if someone is named John Smith, I want him to register under John Smith.

              The ^[A-Za-z ]+$ is enough to unallow users who use other characters like numbers, but I can't manage to restrict users to follow my pattern.

              Comment

              • Colin F
                Senior Member
                • May 2004
                • 17689

                #8
                Try this:
                ^[A-Z][a-zA-Z]+ [A-Z][a-zA-Z]+$
                Best Regards
                Colin Frei

                Please don't contact me per PM.

                Comment

                • pleroy
                  New Member
                  • Jun 2007
                  • 9

                  #9
                  Thanks billion times Colin. This probably still authorize people to register with an expression such as "Big Dog" but it'll avoid most of the nicknames. Now people will read our rules (we have the rules hack set up, explaining the way people have to register, but people never read the rules!).

                  Comment

                  • G_Man
                    New Member
                    • Jan 2006
                    • 7

                    #10
                    Originally posted by Colin F
                    Try this:
                    ^[A-Z][a-zA-Z]+ [A-Z][a-zA-Z]+$
                    Originally posted by pleroy
                    Thanks billion times Colin. This probably still authorize people to register with an expression such as "Big Dog" but it'll avoid most of the nicknames. Now people will read our rules (we have the rules hack set up, explaining the way people have to register, but people never read the rules!).
                    WOW!!! Just in time guys!!! Cheers!!

                    @pleroy - you said it brother. Its like they are all mentally retarded or something, but we both know its just laziness.... grrr!! LOL

                    Thanks Again!!!
                    Wade

                    Comment

                    • vgevolution
                      New Member
                      • Nov 2006
                      • 7
                      • 3.6.x

                      #11
                      Originally posted by jmurrayhead
                      Hello,

                      I want to require users enter their username in this format:

                      firstname.lastname00

                      Where firstname would be A-Za-z, the period is mandatory, lastname would also be A-Za-z, and the 00 is optional 0-9. For example, a user could have the following:

                      john.doe
                      john.doe1
                      john.doe12

                      Would anybody be able to assist me with this?

                      Cheers!
                      This is a really old request, but I didn't see a posted answer.

                      This should work for the original post:
                      ^[A-Za-z]+\.[A-Za-z]+[0-9]{0,2}$
                      Broken down between the ^ and $ boundary, this is:
                      1. [A-Za-z]+ matches the alpha first name, "john"
                      2. \. matches the mandatory character, "."
                      3. [A-Za-z]+ matches the alpha last name, "doe"
                      4. [0-9]{0,2} optionally matches "1", or "12", but fails with "123"

                      Therefore, "Big Dog", "BigDog" or b1g.D0G" will fail,
                      but "Big.Dog", "Big.dog2" or "big.dog57" will pass.

                      Anyone want to confirm it? I don't have a test board up right now, but I'm pretty certain the regex is correct. To change the fourth token to force two mandatory numbers, like "00" or "76", make it [0-9]{2} and you'll be forced to use two numeric characters.

                      Here's another handy use for this repetition limiter syntax. Say you wanted a format like the original post request, but wanted to limit the number of characters for "first name" and "last name". You could use this:
                      ^[A-Za-z]{1,8}\.[A-Za-z]{2,10}[0-9]{0,2}$
                      This is broken down like so:
                      1. [A-Za-z]{1,8} matches the alpha first name, from 1 to 8 characters
                      2. \. matches the mandatory character, "."
                      3. [A-Za-z]{2,10} matches the alpha last name, from 2 to 10 characters
                      4. [0-9]{0,2} optionally matches "1", or "12", but fails with "123"

                      I hope it's okay to to reply to something this old.

                      If this syntax (repetition limiter: {min,max} ) is not allowed, my apologies!

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...