def get_delimited(s, offset, delim):
    """ Collect text from the string `s` from position `offset` up
      to the first occurence of delimiter `delim`; return the text
      excluding the delimiter and the offset after the delimiter.
  """
    pos = s.find(delim, offset)
    if pos < offset:
        raise ValueError('delimiter %r not found after offset %d' % (delim,
            offset))
    return s[offset:pos], pos + len(delim)
