Php Regex Tweet Filter
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 t
Solution 1:
You can go 2 ways. Or you filter them out before sending them to your database. In that case you could use:
if (preg_match('/\#vertraging/i', $tweet)
{
//Insert in DB
}
If you want to insert all of them, but only select the ones with #vertraging from your database, you can use this WHERE clause in your query
WHERE `tweetsText' LIKE '%#vertraging%'Solution 2:
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` WHERELOWER(`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` SIMILARTO'%#(Vertraging|vertraging)%'Hope that helps!
Post a Comment for "Php Regex Tweet Filter"