{"id":121,"date":"2009-09-22T14:12:05","date_gmt":"2009-09-22T21:12:05","guid":{"rendered":"http:\/\/kai.mactane.org\/blog\/2009\/09\/22\/what-characters-are-allowed-in-twitter-usernames\/"},"modified":"2013-02-22T09:20:20","modified_gmt":"2013-02-22T17:20:20","slug":"what-characters-are-allowed-in-twitter-usernames","status":"publish","type":"post","link":"https:\/\/kagan.mactane.org\/blog\/2009\/09\/22\/what-characters-are-allowed-in-twitter-usernames\/","title":{"rendered":"What Characters Are Allowed in Twitter Usernames"},"content":{"rendered":"<p>A while back, when I was writing Hummingbird, I needed to look for Twitter usernames in various strings. More recently, I&#8217;m doing some work that involves Twitter at my new job. Once again, I need to find and match on Twitter usernames.<\/p>\n<p>Luckily, this time, Twitter seems to have updated its signup page with some nice AJAX that constrains the user&#8217;s options, and provides helpful feedback. So, for anyone else who needs this information in the future, here&#8217;s the scoop:<\/p>\n<ol>\n<li>Letters, numbers, and underscores only. It&#8217;s case-blind, so you can enter <code>hi_there<\/code>, <code>Hi_There<\/code>, or <code>HI_THERE<\/code> and they&#8217;ll all work the same (and be treated as a single account).<\/li>\n<li>There is apparently no minimum-length requirement; <a href=\"https:\/\/twitter.com\/a\">the user a exists on Twitter<\/a>. Maximum length is 15 characters.<\/li>\n<li>There is also no requirement that the name contain letters at all; <a href=\"https:\/\/twitter.com\/69\">the user 69<\/a> exists, as does a user <a href=\"https:\/\/twitter.com\/____\">whose name I can&#8217;t pronounce<\/a>.<\/li>\n<\/ol>\n<p>If you want a regex to match on this, <code>\/[a-zA-Z0-9_]{1,15}\/<\/code> would be nice and safe for use in both POSIX and Perl-style regex syntax. (If you&#8217;ve got Perl-compatible regexes, <code>\/\\w{1,15}\/<\/code> is quick and easy. <strong>Update:<\/strong> And <em>it&#8217;s wrong<\/em>; see comment 6 below, by Mark Fowler.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while back, when I was writing Hummingbird, I needed to look for Twitter usernames in various strings. More recently, I&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,62,71,64,36,72],"_links":{"self":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/121"}],"collection":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/comments?post=121"}],"version-history":[{"count":4,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/121\/revisions"}],"predecessor-version":[{"id":122,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/121\/revisions\/122"}],"wp:attachment":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/media?parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/categories?post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/tags?post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}