LuaNET, the lua 5.1 api documentation!

Lua-Api

String

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 missing

March 26, 2007, 11:59:57 AM, DracoBlue
Currently this function doesn't support the third limit parameter.
© 2007 DracoBlue :: Valid XHTML, CSS, RSS Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC | SourceNet © 2007, DracoBlue :: Page created in 0.244 seconds with 71 queries.