Search code examples
regextwitter

Twitter Name Validation


In our registration form we now want to ask the user to enter their twitter name (eg @paul).

Can anyone tell what characters are allowed in it?

e.g. a-z, A-Z, underscores, 0-9

anything else?


Solution

  • I believe it's letters, numbers and underscores only, and a maximum of 15 characters.

    A quick search unveiled this post (non-Twitter) covering the same topic:

    http://kagan.mactane.org/blog/2009/09/22/what-characters-are-allowed-in-twitter-usernames/

    The above post also contains regex examples to help you validate:

    Full regex – /^[a-zA-Z0-9_]{1,15}$/
    Perl-compatible regex – /^\w{1,15}$/