How do I turn a string into an array in Lua? -


  s = "This is a test string" in word = {} s for w: gmatch ("% W + ") Using this table, I could have separated each word but now I just need to use nine words. For example how can I just print another word? I can convert it to an array, then some kind of  
  print word [2]    

Like this:

  s =" This is a test string "in word = {} s for w: gmatch ("% w + ") Do Table.insert (word, w) end print (word [2]) - & gt; In addition to printing it is followed by "is":  
   

> is a test string


  print word [2]    

You can only bracket for string literals and table constants, like:

  print "hello, world" print (table. {{"", "Quick", "brown", "fox"}) - - & gt; 4    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -