class String # Like #index but returns a Range. # # require 'facet/string/range' # # "This is a test!".rand('test') #=> 10..13 # def range(s, offset=0) if self.index(s, offset) return ($~.begin(0))..($~.end(0)-1) end nil end end