0.0
No commit activity in last 3 years
No release in over 3 years
Simple regex generator
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 1.16
>= 10.0
>= 3.0
 Project Readme

RegexGenerator Gem Version

Simple library for generating regular expressions

Installation

Add this line to your application's Gemfile:

gem 'regex_generator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install regex_generator

Usage

RegexGenerator.generate('45', 'some text 45')

You can pass target as hash to generate regex with named capturing groups.

You can use additional options to generate regex. For example:

RegexGenerator.generate('45', 'some text 45', exact_target: true)

Or use from command line:

$ generate_regex "target" "text or path/to/file" [options]

Allowed options:

  • :exact_target - When it true regex will generated for exact target value
  • :self_recognition - Symbols that will be represented as itself. Can be string or array
  • :look - :ahead or :behind (:behind by default). To generate regex with text after or before the value
  • :strict_count - When it true regex will generated with strict chars count
  • :title - Regex will generated for provided title. If :title is provided as Hash (i.e. to generate regex with name capturing groups), :title must contains the same keys as target

Contributing

  • 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

License

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