Return to Snippet

Revision: 874
at September 19, 2007 22:23 by yuconner


Updated Code
function split (s,t)
	local l = {n=0}
	local f = function (s)
		l.n = l.n + 1
		l[l.n] = s
	end
	local p = "%s*(.-)%s*"..t.."%s*"
	s = string.gsub(s,"^%s+","")
	s = string.gsub(s,"%s+$","")
	s = string.gsub(s,p,f)
	l.n = l.n + 1
	l[l.n] = string.gsub(s,"(%s%s*)$","")
	return l
end

Revision: 873
at August 16, 2006 22:29 by yuconner


Initial Code
local digits = split("a b c d e f g h i j k l", " ")
for i=1,6 do
	b = self.panel:get_ButtonBridge_("screen.button_"..digits[i])
	self:connect(b, b.pressed, self, self.button_pressed,i)
end

Initial URL

                                

Initial Description
Example of: split, for, string concatenation, function call, etc

Initial Title
string split in lua

Initial Tags

                                

Initial Language
Lua