https://github.com/mrnovalles/hashtag_parser
A ruby hashtag parser that given a string returns an array with an object with text, start and end for each hashtag
https://github.com/mrnovalles/hashtag_parser
hashtags ruby
Last synced: about 1 year ago
JSON representation
A ruby hashtag parser that given a string returns an array with an object with text, start and end for each hashtag
- Host: GitHub
- URL: https://github.com/mrnovalles/hashtag_parser
- Owner: mrnovalles
- License: mit
- Created: 2020-04-02T15:18:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-18T13:17:33.000Z (over 2 years ago)
- Last Synced: 2025-04-12T00:44:20.161Z (about 1 year ago)
- Topics: hashtags, ruby
- Language: Ruby
- Homepage:
- Size: 32.2 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# HashtagParser
[](https://travis-ci.org/zucaritask/hashtag_parser)
A hashtag parser that brings the behavior of [hashtag-rs](https://github.com/tonsser/hashtag-rs)
to ruby and the work of using an Finite State Machine to do the parsing by [davidpdrsn](https://github.com/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:
```ruby
gem 'hashtag_parser'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install hashtag_parser
## Usage
```ruby
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](http://twitter.com/mrnovalles)
Github: [@mrnovalles](http://github.com/mrnovalles)
## Contributing
1. Fork it
1. Create your feature branch (git checkout -b my-new-feature)
1. Commit your changes (git commit -am 'Add some feature')
1. Push to the branch (git push origin my-new-feature)
1. Create new Pull Request
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).