module Enumerable

Public Instance Methods

grep_indices( regexp ) click to toggle source

Returns [array-index, string-index, string-index] triples for each match.

# File lib/diakonos/core-ext/enumerable.rb, line 3
def grep_indices( regexp )
  array = Array.new
  each_with_index do |element,index|
    element.scan( regexp ) do |match_text|
      match = Regexp.last_match
      strindex = match.begin( 0 )
      array.push [ index, strindex, strindex + match[ 0 ].length ]
    end
  end
  array
end