module Regexp::Scanner

def self.text(data, ts, te, soff = 0)

and the offsets used to copy it.
Copy from ts to te from data as text, returning an array with the text
def self.text(data, ts, te, soff = 0)
  [copy(data, ts-soff..te-1), ts-soff, te]
end