PHP的正则表达式推文过滤器 [英] PHP Regex tweet Filter

查看:188
本文介绍了PHP的正则表达式推文过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。
使用Rstudio,Postgreql,PHP爬取twitter个人资料



我试图从twitter个人资料中过滤推文。

使用PHP与Postgresql。我已经在我的网站上的一个表中使用SQL查询推文。我想用正则表达式来过滤推文。我不想从我的网站上的Twitter个人资料中显示所有的推文,只是一些,如包含#Vertraging的推文。现在,我在我的网站上看到了所有的推文。



如何排除不包含#vertraging的所有推文?



查看我的网站上的表格



http://prntscr.com/384y5m <如果你使用的是Postgresql,你可以忽略Regex,直接使用就像

解决方案而不是。例如:
$ b $ pre $ SELECT * FROM`tweets_table` WHERE`tweet_content` LIKE'%#Vertraging%'
code>

这应该和正则表达式一样,可能更多。希望有所帮助!如果你担心大写/小写,你可以做两件事:

  SELECT * FROM`tweets_table` WHERE LOWER(`tweet_content`)LIKE'%#vertraging%'

或者您可以使用<$ c $类似于。但是,我只是使用 lower 替代方法。

  SELECT * FROM`tweets_table` WHERE`tweet_content`与〜%%(顶点)%'

这有帮助!

i have a question. Im crawling a twitter profile, using Rstudio,Postgreql,PHP

Im trying to filter tweets from a twitter profile.

Im using php with postgresql . I already have the tweets in a table on my website using SQL Query. I would like to use Regex to filter the tweets. I dont want to show all of the tweets from the twitter profile on my website, just some, like tweets containing #Vertraging. Now i see all of the tweets on my website.

How can i exclude all the tweets not containing #vertraging?

see screenshot for my table on my website

http://prntscr.com/384y5m

解决方案

If you're using Postgresql, you can ignore Regex and use straight like instead. For instance:

SELECT * FROM `tweets_table` WHERE `tweet_content` LIKE '%#Vertraging%'

That should be as performant as regex and probably more. Hope that helps! If you're worried about uppercase/lowercase, there are two different things you can do:

SELECT * FROM `tweets_table` WHERE LOWER(`tweet_content`) LIKE '%#vertraging%'

or you can use similar to. However, I'd just use the lower alternative.

SELECT * FROM `tweets_table` WHERE `tweet_content` SIMILAR TO '%#(Vertraging|vertraging)%'

Hope that helps!

这篇关于PHP的正则表达式推文过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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