This is a simple helper to extract values from a string based on a pattern.
A Ruby port of laktek's extract-values.
Add this line to your application's Gemfile:
gem 'excise'
And then execute:
$ bundle
Or install it yourself as:
$ gem install excise
require 'excise'
# Basic use
pattern_text = 'About {result_count} results'
Excise(pattern_text, 'About 49,000 results') #=> {:result_count=>"49,000"}
# Memoize pattern for performance improvement
pattern = Excise.new(pattern_text)
pattern.parse 'About 49,000,000 results' #=> {:result_count=>"49,000,000"}
pattern.parse 'About 1,000 results' #=> {:result_count=>"1,000"}
- 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