I am trying to extract the mentions in a Tweet from Twitter i.e. @Google or @Apple.
This is my code so far to extract the mentions from a column and then create another column with the mentions.
df_bdtu['mentions'] = df_bdtu['tweet_text'].str.findall('(?:^|\s)[@ @]{1}([^\s#<>[\]|{}]+)')
It works mostly but I am facing some issues with some edge cases for example take this Tweet:
Check out @Dreams_n_Songs and give them a follow! I can't recommend their hoodies enough!Shop now …
The mentions stored in the mentions column below which is incorrect as it includes the emoji for some reason.
['Dreams_n_Songs', '…']
Another issue is when there is a . before the mentions such as this example:
.@ChelseaFC, @FCBayern, @VfL_Wolfsburg and more are among the latest names to be confirmed at -…
The mentions that are produced do not include the first mention.
[FCBayern,, VfL_Wolfsburg]
How would I fix the regex for this?