class MatchData

def byteoffset(n)

def byteoffset(n)
  if (char_start_offset = self.begin(n))
    char_end_offset = self.end(n)
    [string[0, char_start_offset].bytesize, string[0, char_end_offset].bytesize]
  else
    [nil, nil]
  end
end

def match(index)

def match(index)
  self[index]
end

def match_length(index)

def match_length(index)
  m = self[index]
  m && m.length
end

def named_captures_with_symbolize_option(symbolize_keys: false)

def named_captures_with_symbolize_option(symbolize_keys: false)
  captures = named_captures_without_symbolize_option
  captures.transform_keys!(&:to_sym) if symbolize_keys
  captures
end