explode function explode ( seperator, str )
local pos, arr = 0, {}
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
table.insert( arr, string.sub( str, pos, st-1 ) ) -- Attach chars left of current divider
pos = sp + 1 -- Jump past current divider
end
table.insert( arr, string.sub( str, pos ) ) -- Attach chars right of last divider
return arr
end
A function which shows same behaviour like php's explode or javascript's split.
Comments
limit missingMarch 26, 2007, 11:59:57 AM, DracoBlue
Currently this function doesn't support the third limit parameter.
|