Sha256: cb92c0840545004a21c9c770edb70aebe844bcbc09a5ca69aa7db93154ba6e07
Contents?: true
Size: 404 Bytes
Versions: 9
Compression:
Stored size: 404 Bytes
Contents
class String def naive_split(pattern) string = self.dup found = [] while position = string.index(pattern) found << string.slice!(0, position) string.slice!(0,[pattern.size,1].max) end found << string found end def nth_index(text, n) offset = -1 (n+1).times do offset += 1 offset = index(text, offset) or return end offset end end
Version data entries
9 entries across 9 versions & 1 rubygems