class MatchData

Public Instance Methods

byteoffset(n) click to toggle source
# File lib/backports/3.2.0/match_data/byteoffset.rb, line 3
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
match(index) click to toggle source
# File lib/backports/3.1.0/match_data/match.rb, line 2
def match(index)
  self[index]
end
match_length(index) click to toggle source
# File lib/backports/3.1.0/match_data/match_length.rb, line 2
def match_length(index)
  m = self[index]
  m && m.length
end