fork download
  1. import re
  2.  
  3. tweet = 'New PyBites article: Module of the Week - Requests-cache for Repeated API Calls - http://p...content-available-to-author-only...t.es/requests-cache.html #python #APIs'
  4.  
  5. # Get all hashtags and links from tweet
  6. def get_hashtags_and_links(tweet=tweet):
  7. tweet_regex = re.compile(r'''
  8. \#\w+ # Hashtag pattern
  9. | # or
  10. https?://\S+ # URLs
  11. ''', re.VERBOSE)
  12.  
  13. tweet_object = tweet_regex.findall(tweet)
  14. print(tweet_object)
  15.  
  16. get_hashtags_and_links()
Success #stdin #stdout 0.02s 9360KB
stdin
Standard input is empty
stdout
['http://p...content-available-to-author-only...t.es/requests-cache.html', '#python', '#APIs']