We Recommend

HTML: The Definitive Guide HTML: The Definitive Guide
They teach you that learning HTML is like learning any other language and that reading a book of rules can only take you so far. Readers begin writing what may be their first Web page just two pages into the book's second chapter. From there on, they provide a wide range of HTML coding to allow readers to learn from good examples. The book includes a handy "cheat sheet" of HTML codes for quick reference.


Posted By

yuconner on 08/16/06


Tagged


Versions (?)


string split in lua


Published in: Lua 


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


  1. function split (s,t)
  2. local l = {n=0}
  3. local f = function (s)
  4. l.n = l.n + 1
  5. l[l.n] = s
  6. end
  7. local p = "%s*(.-)%s*"..t.."%s*"
  8. s = string.gsub(s,"^%s+","")
  9. s = string.gsub(s,"%s+$","")
  10. s = string.gsub(s,p,f)
  11. l.n = l.n + 1
  12. l[l.n] = string.gsub(s,"(%s%s*)$","")
  13. return l
  14. end

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: yuconner on September 19, 2007

-- (based on piece of code used for the QT wrapper library) local digits = split("a b c d e f g h i j k l", " ") for i=1,6 do b = self.panel:getButtonBridge("screen.button"..digits[i]) self:connect(b, b.pressed, self, self.buttonpressed,i) end

You need to login to post a comment.