class Regexp::Expression::Subexpression

def each_expression(include_self = false, &block)

the expression and its index within its parent to the given block.
Iterates over the expressions of this expression as an array, passing
def each_expression(include_self = false, &block)
  return enum_for(__method__, include_self) unless block_given?
  traverse(include_self) do |event, exp, index|
    yield(exp, index) unless event == :exit
  end
end