module Gemmy::Patches::StringPatch::InstanceMethods::Range

Public Instance Methods

range(pattern, offset=0) click to toggle source

facets Gets the start/end indexes of a match to <pattern> only considers first match

# File lib/gemmy/patches/string_patch.rb, line 103
def range(pattern, offset=0)
  unless Regexp === pattern
    pattern = Regexp.new(Regexp.escape(pattern.to_s))
  end
  string = self[offset..-1]
  if md = pattern.match(string)
    return (md.begin(0)+offset)..(md.end(0)+offset-1)
  end
  nil
end