Reputation: 13
This is for Matlab. I have a tweet and I need to find what the hashtags say. I know I can isolate and save to a variable everything that starts with a '#' and ends with a ' ' using regexp. But, when I use
tweet = 'it is fun to post on #stackoverflow, really #itis';
regexp(tweet,'#(\w+)','tokens','once')
ans =
'stackoverflow'
I only get the first #. How would I make it so that I could get the "itis" # as well?
Upvotes: 1
Views: 371
Reputation: 116
I think this is what you're looking for:
regexp(tweet,'#(\w+)','match')
ans =
'#stackoverflow' '#itis'
However, it seems as if you know more about Regex than I do, so I guess you know how to get rid of the #
's in the string.
Upvotes: 0
Reputation: 56
According to the matlab documentation, you need to remove the 'once'. Source: http://www.mathworks.com/help/matlab/ref/regexp.html
Upvotes: 0