从推文中检索所有主题标签 [英] Retrieve all hashtags from a tweet

查看:29
本文介绍了从推文中检索所有主题标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Twitter API 来检索单个推文中存在的所有主题标签的列表?

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

例如,假设我有一条推文(假设它的 ID 为 12345),内容如下:

For example, let's say I have a tweet (let's say it has an ID of 12345) with the following text:

嗨.我喜欢#stackoverflow,因为它是#superawesome.#fb

Hi. I love #stackoverflow because it's #superawesome. #fb

是否有一个 API 调用可以让我返回#stackoverflow、#superawesome 和 &#fb 当我给它 12345 的 ID 时?

Is there an API call that will give me back #stackoverflow, #superawesome, & #fb when I give it an ID of 12345?

还是我必须自己解析推文的文本?

Or do I just have to parse the text of the tweet myself?

推荐答案

您必须使用所选语言的正则表达式

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.

这篇关于从推文中检索所有主题标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆