Module: RegexGenerator

Defined in:
lib/regex_generator.rb,
lib/regex_generator/target.rb,
lib/regex_generator/version.rb,
lib/regex_generator/generator.rb,
lib/regex_generator/exceptions.rb,
lib/regex_generator/characters_recognizer.rb

Defined Under Namespace

Classes: CharactersRecognizer, Generator, Target, TargetNotFoundError

Constant Summary collapse

VERSION =
'0.3.2'

Class Method Summary collapse

Class Method Details

.generate(target, text, options = {}) ⇒ Regexp

Generates regex by text and target text

Examples:

Generate regex

RegexGenerator.generate('45', 'some text 45') #=> /[a-z]+\s[a-z]+(\d+)/

Parameters:

  • what you want to find

  • source text

  • (defaults to: {})

    options to generate regex with

Options Hash (options):

  • :exact_target (true, false)

    to generate regex with exact target value

Returns:



20
21
22
# File 'lib/regex_generator.rb', line 20

def self.generate(target, text, options = {})
  RegexGenerator::Generator.new(target, text, options).generate
end