Retrieve all hashtags from a tweet

后端 未结 4 1704
情歌与酒
情歌与酒 2021-01-15 10:26

Is it possible using the Twitter API to retrieve a list of all hashtags present within a single tweet?

For example, let\'s say I have a tweet (let\'s say it has an I

相关标签:
4条回答
  • 2021-01-15 10:55

    Although @ialphan's solution is good, if you want to sort hashtags with occurance just use this answer in similar question:
    Retrieve all hashtags from a tweet in a PHP function

    0 讨论(0)
  • 2021-01-15 10:56

    You can use Tweet Entities. Just include &include_entities=1.

    0 讨论(0)
  • 2021-01-15 10:58

    The Twitter API does not have any functions specifically designed for hashtags. You'll need to parse the text on your own.

    0 讨论(0)
  • 2021-01-15 11:03

    You'll have to use a regular expression in your language of choice

       #\S+
    

    should match any hash, beginning with # and made of a string of characters. It stops at the first space.

    If you want to exclude any trailing symbol and have a letter as the last char :

    #\S*\w
    

    This expression should work in most of the regex engines I'm aware of.

    0 讨论(0)
提交回复
热议问题