class MatchData

Helper functions to return character offsets instead of byte offsets.

Public Instance Methods

char_begin(n) click to toggle source
# File lib/twitter-text/extractor.rb, line 28
def char_begin(n)
  if string.respond_to? :codepoints
    self.begin(n)
  else
    string[0, self.begin(n)].char_length
  end
end
char_end(n) click to toggle source
# File lib/twitter-text/extractor.rb, line 36
def char_end(n)
  if string.respond_to? :codepoints
    self.end(n)
  else
    string[0, self.end(n)].char_length
  end
end