Module: Enumerable
- Defined in:
- lib/diakonos/core-ext/enumerable.rb
Instance Method Summary collapse
-
#grep_indices(regexp) ⇒ Object
Returns [array-index, string-index, string-index] triples for each match.
Instance Method Details
#grep_indices(regexp) ⇒ Object
Returns [array-index, string-index, string-index] triples for each match.
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# 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 = Regexp.last_match strindex = match.begin(0) array.push [ index, strindex, strindex + match[0].length ] end end array end |