0.0
No release in over 3 years
Low commit activity in last 3 years
Hashtag parser inspired by https://github.com/tonsser/hashtag-rs/ Given a string, this gem returns an array with an object with `text`, `start` and `end`. Its goal is to match Instagram's parsing of hashtags.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
 Project Readme

HashtagParser

Build Status

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.

Installation

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

Usage

hashtags = HashtagParser.parse("#ruby is #awesome")

hashtags is going to be:

[
  {
    text: "ruby",
    start: 0,
    end: 4
  },
  {
    text: "awesome",
    start: 9,
    end: 16
  }
]

Contact

Twitter: @mrnovalles

Github: @mrnovalles

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.