lib/regexp-examples/regexp_extensions.rb in regexp-examples-0.0.0 vs lib/regexp-examples/regexp_extensions.rb in regexp-examples-0.0.1
- old
+ new
@@ -1,15 +1,15 @@
class Regexp
module Examples
def examples
- regexp_string = self.inspect[1..-2]
partial_examples =
- RegexpExamples::Parser.new(regexp_string)
+ RegexpExamples::Parser.new(source)
.parse
.map {|repeater| repeater.result}
- full_examples = RegexpExamples::permutations_of_strings(partial_examples)
- full_examples.map{ |full_example| RegexpExamples::BackReferenceReplacer.new.substitute_backreferences(full_example)}
- full_examples
+ full_examples = RegexpExamples::permutations_of_strings(partial_examples.dup, no_join: true)
+ full_examples_with_backrefs = \
+ RegexpExamples::BackReferenceReplacer.new.substitute_backreferences(full_examples)
+ full_examples_with_backrefs.map(&:join)
end
end
include Examples
end