A hashtag parser that brings the behavior of hashtag-rs to ruby and the work of using an Finite State Machine to do the parsing by davidpdrsn
Given a string as "#ruby is #awesome"
, this gem returns an array with an object with text
, start
and end
for each of the two hashtags in the string.
Its goal is to match Instagram's parsing of hashtags.
Add this line to your application's Gemfile:
gem 'hashtag_parser'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install hashtag_parser
hashtags = HashtagParser.parse("#ruby is #awesome")
hashtags
is going to be:
[
{
text: "ruby",
start: 0,
end: 4
},
{
text: "awesome",
start: 9,
end: 16
}
]
Twitter: @mrnovalles
Github: @mrnovalles
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
The gem is available as open source under the terms of the MIT License.