/ Published in: Lua
Example of: split, for, string concatenation, function call, etc
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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