On the page of the documentation titled, “How Twitter wraps URLs with t.co” (https://dev.twitter.com/docs/tco-url-wrapper/how-twitter-wrap-urls), it references various code libraries you can use to detect @mentions, hashtags, and urls in a string. This is great because it is extremely difficult to do, especially now that Twitter is turning non-http protocol text like “MySite.com” into a t.co link.
I wanted to do this for python and tried out the python library (https://github.com/BonsaiDen/twitter-text-python), but found that the code has not be updated to recognize non-protocol links like “MySite.com”.
Luckily, someone has done the work for Twitter (and me!), see https://github.com/mccutchen/twitter-url-regexen
I hope someone at Twitter can either update the code they are referencing, or reference the code I just mentioned. Thanks!