Here's the regex that I'm using for hashtag extraction
def extract_hashtags
hashtag_regex = /\B#(\w+)/i
text_hashtags = content.scan(hashtag_regex)
text_hashtags.each do |tag|
hashtags.create hashtags: tag
end
end
Using /\B#(\w+)/i
, leaves this in the front of the data
For example, the extraction should be "abcd", but it is saved as "--- - abcd"
What should the regex be change to in order to extract just the #abcd?
If the post content (where the hashtag is extracted) is something like "Hello stackoverflow #stackoverflow", it gets saved into the database as "-- - stackoverflow"