![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
A while back, when I was writing Hummingbird, I needed to look for Twitter usernames in various strings. More recently, I’m doing some work that involves Twitter at my new job. Once again, I need to find and match on Twitter usernames.
Luckily, this time, Twitter seems to have updated its signup page with some nice AJAX that constrains the user’s options, and provides helpful feedback. So, for anyone else who needs this information in the future, here’s the scoop:
- Letters, numbers, and underscores only. It’s case-blind, so you can enter
hi_there
,Hi_There
, orHI_THERE
and they’ll all work the same (and be treated as a single account). - There is apparently no minimum-length requirement; the user a exists on Twitter. Maximum length is 15 characters.
- There is also no requirement that the name contain letters at all; the user 69 exists, as does a user whose name I can’t pronounce.
If you want a regex to match on this, /[a-zA-Z0-9_]{1,15}/
would be nice and safe for use in both POSIX and Perl-style regex syntax. (If you’ve got Perl-compatible regexes, /\w{1,15}/
is quick and easy.)
Originally published at Coyote Tracks. You can comment here or there.